Module: Reflex::ModelOwner

Included in:
ModelView
Defined in:
lib/reflex/model_owner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modelObject

Returns the value of attribute model.



9
10
11
# File 'lib/reflex/model_owner.rb', line 9

def model
  @model
end

Instance Method Details

#dataObject



29
30
31
# File 'lib/reflex/model_owner.rb', line 29

def data()
  @model ? @model.data : nil
end

#data=(data) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/reflex/model_owner.rb', line 19

def data=(data)
  unless data.nil?
    self.model = Model.new unless @model
    @model.data = data
  else
    self.model = nil
  end
  data
end

#invoke(*args) ⇒ Object



33
34
35
# File 'lib/reflex/model_owner.rb', line 33

def invoke(*args)
  @model.invoke(*args) if @model
end

#on_data_attach(e) ⇒ Object



37
38
39
# File 'lib/reflex/model_owner.rb', line 37

def on_data_attach(e)
  invoke :update, {}, only: self
end

#on_data_detach(e) ⇒ Object



41
42
43
# File 'lib/reflex/model_owner.rb', line 41

def on_data_detach(e)
  invoke :update, {}, only: self
end