module Neo4j::ActiveNode::Reflection::ClassMethods

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

Public Instance Methods

reflect_on_all_associations(macro = nil) click to toggle source

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

   # File lib/neo4j/active_node/reflection.rb
31 def reflect_on_all_associations(macro = nil)
32   association_reflections = reflections.values
33   macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections
34 end
reflect_on_association(association) click to toggle source

@param association [Symbol] an association declared on the model @return [Neo4j::ActiveNode::Reflection::AssociationReflection] of the given association

   # File lib/neo4j/active_node/reflection.rb
26 def reflect_on_association(association)
27   reflections[association.to_sym]
28 end

Private Instance Methods

create_reflection(macro, name, association_object, model) click to toggle source

@param macro [Symbol] the association type, :has_many or :has_one @param name [Symbol] the association name @param association_object [Neo4j::ActiveNode::HasN::Association] the association object created in the course of creating this reflection

   # File lib/neo4j/active_node/reflection.rb
18 def create_reflection(macro, name, association_object, model)
19   self.reflections = self.reflections.merge(name => AssociationReflection.new(macro, name, association_object))
20   association_object.add_destroy_callbacks(model)
21 end