Class: Oedipus::DataMapper::DefaultProc::Get
- Inherits:
-
Object
- Object
- Oedipus::DataMapper::DefaultProc::Get
- Defined in:
- lib/oedipus/data_mapper/default_proc.rb
Instance Method Summary collapse
- #call(resource) ⇒ Object
-
#initialize(model, attr) ⇒ Get
constructor
A new instance of Get.
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 |