Class: DataMapper::Associations::RelationshipChain

Inherits:
Relationship show all
Defined in:
lib/gems/dm-core-0.9.9/lib/dm-core/associations/relationship_chain.rb

Constant Summary collapse

OPTIONS =
[
  :repository_name, :near_relationship_name, :remote_relationship_name,
  :child_model, :parent_model, :parent_key, :child_key,
  :min, :max
]

Instance Attribute Summary

Attributes inherited from Relationship

#name, #options, #query

Instance Method Summary collapse

Methods inherited from Relationship

#attach_parent, #child_key, #get_parent, #parent_key, #parent_model, #with_repository

Methods included from DataMapper::Assertions

#assert_kind_of

Instance Method Details

#child_modelObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/associations/relationship_chain.rb', line 14

def child_model
  near_relationship.child_model
end

#get_children(parent, options = {}, finder = :all, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/associations/relationship_chain.rb', line 19

def get_children(parent, options = {}, finder = :all, *args)
  query = @query.merge(options).merge(child_key.to_query(parent_key.get(parent)))

  query[:links]  = links
  query[:unique] = true

  with_repository(parent) do
    results = grandchild_model.send(finder, *(args << query))
    # FIXME: remove the need for the uniq.freeze
    finder == :all ? (@mutable ? results : results.freeze) : results
  end
end