Sha256: 70eb1aba94c983df3db26f9ea90b012674a7b9fd6f3975270e80b8304c2b629e
Contents?: true
Size: 757 Bytes
Versions: 2
Compression:
Stored size: 757 Bytes
Contents
module GdatastoreMapper class Relation < Array def initialize(klass, association) @klass = klass @association = association end def create attributes belonging = create_belonging attributes update_owner belonging end private def create_belonging attributes belonging_attr = attributes.merge(@association.owner_attributes) @association.belonging_klass.create(belonging_attr) end def update_owner belonging existing_ids = @association.owner.send(@association.belonging_id) existing_ids = [] if existing_ids.nil? owner_attr = {} owner_attr[@association.belonging_id] = (existing_ids << belonging.id) @association.owner.update(owner_attr) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gdatastore_mapper-0.1.2 | lib/gdatastore_mapper/relation.rb |
gdatastore_mapper-0.1.2bata | lib/gdatastore_mapper/relation.rb |