Method: CaringForm::Model#initialize

Defined in:
lib/caring_form/model.rb

#initialize(attributes = {}) ⇒ Model

attributes can be scoped within key of the name of the class (posted form) or a flat hash of attributes



16
17
18
19
20
21
22
23
24
25
# File 'lib/caring_form/model.rb', line 16

def initialize(attributes = {})
  flatten_attributes(attributes).each do |name, value|
    send("#{name}=", normalize_attribute_value(name, value)) if respond_to?(name)
  end
  (INHERITED_ATTRIBUTES - attributes.keys).each do |name|
    value = self.class.send(name)
    send("#{name}=", value) unless value.nil?
  end
  after_initialize
end