Module: DataMapper::NestedAttributes::OneToMany
- Defined in:
- lib/dm-accepts_nested_attributes/relationship.rb
Overview
Extensions for Associations::OneToMany::Relationship.
Instance Method Summary collapse
Instance Method Details
#extract_keys_for_nested_attributes(model, attributes) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dm-accepts_nested_attributes/relationship.rb', line 38 def extract_keys_for_nested_attributes(model, attributes) keys = self.child_model.key.to_enum(:each_with_index).map do |key, idx| if parent_idx = self.child_key.to_a.index(key) model[self.parent_key.to_a.at(parent_idx).name] else attributes[key.name] end end keys.any? { |key| DataMapper::Ext.blank?(key) } ? nil : keys end |