Module: StrokeDB::Associations::HasManyAssociation

Defined in:
lib/strokedb/document/dsl/associations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#association_ownerObject (readonly)

Returns the value of attribute association_owner.



6
7
8
# File 'lib/strokedb/document/dsl/associations.rb', line 6

def association_owner
  @association_owner
end

#association_slotnameObject (readonly)

Returns the value of attribute association_slotname.



6
7
8
# File 'lib/strokedb/document/dsl/associations.rb', line 6

def association_slotname
  @association_slotname
end

Instance Method Details

#<<(doc) ⇒ Object



19
20
21
22
# File 'lib/strokedb/document/dsl/associations.rb', line 19

def <<(doc)
  doc.update_slots! association_reference_slotname => association_owner
  self
end

#create!(slots = {}) ⇒ Object



12
13
14
# File 'lib/strokedb/document/dsl/associations.rb', line 12

def create!(slots={})
  new(slots).save!
end

#find(query = {}) ⇒ Object



16
17
18
# File 'lib/strokedb/document/dsl/associations.rb', line 16

def find(query={})
  association_owner._has_many_association(association_slotname,query)
end

#new(slots = {}) ⇒ Object Also known as: build



7
8
9
# File 'lib/strokedb/document/dsl/associations.rb', line 7

def new(slots={})
  association_meta.constantize.new(association_owner.store, slots.merge({association_reference_slotname => association_owner}))
end