Module: ActiveGraph::Node::Reflection::ClassMethods

Defined in:
lib/active_graph/node/reflection.rb

Overview

Adds methods to the class related to creating and retrieving reflections.

Instance Method Summary collapse

Instance Method Details

#reflect_on_all_associations(macro = nil) ⇒ Object

Returns an array containing one reflection for each association declared in the model.



31
32
33
34
# File 'lib/active_graph/node/reflection.rb', line 31

def reflect_on_all_associations(macro = nil)
  association_reflections = reflections.values
  macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections
end

#reflect_on_association(association) ⇒ ActiveGraph::Node::Reflection::AssociationReflection

Returns of the given association.

Parameters:

  • association (Symbol)

    an association declared on the model

Returns:



26
27
28
# File 'lib/active_graph/node/reflection.rb', line 26

def reflect_on_association(association)
  reflections[association.to_sym]
end