Class: Edgar::ViewStatus

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/edgar/view_status.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) intern(sssn, view, search_obj)



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/edgar/view_status.rb', line 7

def self.intern(sssn, view, search_obj)
  if !sssn || !(vs = sssn.view_status.find_by_view(view))
    vs = ViewStatus.new(
          :sssn_id  => sssn ? sssn.id : nil,
          :view     => view,
          :lines    => 10,
          :order_by => '',
          :dir      => '',
          :page     => 1
        )
    vs.model = search_obj
    vs.save!
  end
  vs
end

Instance Method Details

- (Object) model

de-serialize in model_data and return it



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/models/edgar/view_status.rb', line 31

def model
  if self.model_data
    # FIXME: Following code fixes the error:
    #  - ArgumentError (undefined class/module Search)
    #  - ArgumentError (undefined class/module SearchForm)
    #
    # But some autoload may smartlier fixes this?
    Search
    SearchForm
    Marshal.load(Base64.decode64(self.model_data))
  else
    nil
  end
end

- (Object) model=(model)

serialize model and set it to model_data



25
26
27
# File 'app/models/edgar/view_status.rb', line 25

def model=(model)
  self.model_data = Base64.encode64(Marshal.dump(model))
end