Class: GdatastoreMapper::Relation
- Inherits:
-
Array
- Object
- Array
- GdatastoreMapper::Relation
- Includes:
- QueryMethods
- Defined in:
- lib/gdatastore_mapper/relation.rb
Instance Attribute Summary collapse
-
#association ⇒ Object
Returns the value of attribute association.
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
- #create(attributes) ⇒ Object
-
#initialize(klass, association) ⇒ Relation
constructor
A new instance of Relation.
- #new(attributes) ⇒ Object
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
#association ⇒ Object
Returns the value of attribute association.
7 8 9 |
# File 'lib/gdatastore_mapper/relation.rb', line 7 def association @association end |
#klass ⇒ Object
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 |