Class: Oedipus::DataMapper::DefaultProc::Get

Inherits:
Object
  • Object
show all
Defined in:
lib/oedipus/data_mapper/default_proc.rb

Instance Method Summary collapse

Constructor Details

#initialize(model, attr) ⇒ Get

Returns a new instance of Get.



17
18
19
20
21
# File 'lib/oedipus/data_mapper/default_proc.rb', line 17

def initialize(model, attr)
  @model    = model
  @attr     = attr
  @property = model.properties[attr]
end

Instance Method Details

#call(resource) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/oedipus/data_mapper/default_proc.rb', line 23

def call(resource)
  if @property
    @property.dump(resource[@attr])
  else
    resource.send(@attr)
  end
end