Module: DataMapper::NestedAttributes::ManyToOne
- Defined in:
- lib/dm-accepts_nested_attributes/relationship.rb
Overview
Extensions for Associations::ManyToOne::Relationship.
Instance Method Summary collapse
Instance Method Details
#extract_keys_for_nested_attributes(model, attributes) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dm-accepts_nested_attributes/relationship.rb', line 53 def extract_keys_for_nested_attributes(model, attributes) keys = self.parent_model.key.to_enum(:each_with_index).map do |key, idx| if child_idx = self.parent_key.to_a.index(key) model[self.child_key.to_a.at(child_idx).name] else attributes[key.name] end end keys.any? { |key| DataMapper::Ext.blank?(key) } ? nil : keys end |