Class: GdatastoreMapper::Relation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from QueryMethods

#find, #find_by, #find_or_create, #limit, #order, #where

Constructor Details

#initialize(klass, association) ⇒ Relation

Returns a new instance of Relation.



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

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

Instance Attribute Details

#associationObject

Returns the value of attribute association.



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

def association
  @association
end

#klassObject

Returns the value of attribute klass.



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

def klass
  @klass
end

Instance Method Details

#create(attributes) ⇒ Object



19
20
21
22
23
# File 'lib/gdatastore_mapper/relation.rb', line 19

def create attributes
  belonging = create_belonging attributes
  update_owner belonging
  belonging
end

#new(attributes) ⇒ Object



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

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