Class: GdatastoreMapper::Associations::HasMany

Inherits:
Object
  • Object
show all
Defined in:
lib/gdatastore_mapper/associations/has_many.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, belonging) ⇒ HasMany

Returns a new instance of HasMany.



7
8
9
10
# File 'lib/gdatastore_mapper/associations/has_many.rb', line 7

def initialize(owner, belonging)
  @owner = owner
  @belonging = belonging
end

Instance Attribute Details

#belongingObject

Returns the value of attribute belonging.



5
6
7
# File 'lib/gdatastore_mapper/associations/has_many.rb', line 5

def belonging
  @belonging
end

#ownerObject

Returns the value of attribute owner.



5
6
7
# File 'lib/gdatastore_mapper/associations/has_many.rb', line 5

def owner
  @owner
end

Instance Method Details

#belonging_idObject



22
23
24
# File 'lib/gdatastore_mapper/associations/has_many.rb', line 22

def belonging_id
  @belonging.to_s + '_id'
end

#belonging_klassObject



12
13
14
# File 'lib/gdatastore_mapper/associations/has_many.rb', line 12

def belonging_klass
  @belonging.to_s.classify.constantize
end

#owner_attributesObject



16
17
18
19
20
# File 'lib/gdatastore_mapper/associations/has_many.rb', line 16

def owner_attributes
  {
    (@owner.class.to_s.underscore + '_id') => @owner.id
  }
end