Class: Oedipus::DataMapper::DefaultProc::Set
- Inherits:
-
Object
- Object
- Oedipus::DataMapper::DefaultProc::Set
- Defined in:
- lib/oedipus/data_mapper/default_proc.rb
Instance Method Summary collapse
- #call(resource, value) ⇒ Object
-
#initialize(model, attr) ⇒ Set
constructor
A new instance of Set.
Constructor Details
#initialize(model, attr) ⇒ Set
Returns a new instance of Set.
33 34 35 36 37 |
# File 'lib/oedipus/data_mapper/default_proc.rb', line 33 def initialize(model, attr) @model = model @attr = attr @property = model.properties[attr] end |
Instance Method Details
#call(resource, value) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/oedipus/data_mapper/default_proc.rb', line 39 def call(resource, value) if @property resource[@attr] = @property.load(value) else resource.send("#{@attr}=", value) end end |