Class: GdatastoreMapper::Relation

Inherits:
Array
  • Object
show all
Defined in:
lib/gdatastore_mapper/relation.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass, association) ⇒ Relation

Returns a new instance of Relation.



3
4
5
6
# File 'lib/gdatastore_mapper/relation.rb', line 3

def initialize(klass, association)
  @klass = klass
  @association = association
end

Instance Method Details

#create(attributes) ⇒ Object



13
14
15
16
17
# File 'lib/gdatastore_mapper/relation.rb', line 13

def create attributes
  belonging = create_belonging attributes
  update_owner belonging
  belonging
end

#new(attributes) ⇒ Object



8
9
10
11
# File 'lib/gdatastore_mapper/relation.rb', line 8

def new attributes
  belonging_attr = attributes.merge(@association.owner_attributes)
  @association.belonging_klass.new(belonging_attr)
end