Module: Datamappify::Data::Criteria::Concerns::UpdatePrimaryRecord
- Included in:
- ActiveRecord::Save, Sequel::Save
- Defined in:
- lib/datamappify/data/criteria/concerns/update_primary_record.rb
Instance Method Summary collapse
- #save(record) ⇒ Object private
- #update_primary_record_with(record) ⇒ Object private
Instance Method Details
#save(record) ⇒ Object (private)
8 9 10 11 12 13 14 |
# File 'lib/datamappify/data/criteria/concerns/update_primary_record.rb', line 8 def save(record) if && [:via] && [:primary_record] update_primary_record_with(record) end record end |
#update_primary_record_with(record) ⇒ Object (private)
16 17 18 19 20 21 22 23 |
# File 'lib/datamappify/data/criteria/concerns/update_primary_record.rb', line 16 def update_primary_record_with(record) save = self.class.superclass.new([:primary_record].class, entity, { :id => [:primary_record].id }) save.attributes_and_values = { [:via] => record.id } save.send(:save_record) end |