Module: StoreModel::NestedAttributes::ClassMethods

Defined in:
lib/store_model/nested_attributes.rb

Instance Method Summary collapse

Instance Method Details

#accepts_nested_attributes_for(*associations) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/store_model/nested_attributes.rb', line 10

def accepts_nested_attributes_for(*associations)
  associations.each do |association|
    case attribute_types[association.to_s]
    when Types::JsonType
      alias_method "#{association}_attributes=", "#{association}="
    when Types::ArrayType
      define_method "#{association}_attributes=" do |attributes|
        assign_nested_attributes_for_collection_association(association, attributes)
      end
    end
  end
end