Class: Oedipus::DataMapper::DefaultProc::Set

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

Instance Method Summary collapse

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