class ActiveGraph::Node::Reflection::AssociationReflection
The actual reflection object that contains information about the given association. These should never need to be created manually, they will always be created by declaring a :has_many or :has_one association on a model.
Attributes
association[R]
The association object referenced by this reflection
macro[R]
The type of association
name[R]
The name of the association
Public Class Methods
new(macro, name, association)
click to toggle source
# File lib/active_graph/node/reflection.rb 49 def initialize(macro, name, association) 50 @macro = macro 51 @name = name 52 @association = association 53 end
Public Instance Methods
class_name()
click to toggle source
Returns the name of the target model
# File lib/active_graph/node/reflection.rb 61 def class_name 62 @class_name ||= association.target_class.name 63 end
collection?()
click to toggle source
# File lib/active_graph/node/reflection.rb 77 def collection? 78 macro == :has_many 79 end
klass()
click to toggle source
Returns the target model
# File lib/active_graph/node/reflection.rb 56 def klass 57 @klass ||= class_name.constantize 58 end
rel_class_name()
click to toggle source
# File lib/active_graph/node/reflection.rb 69 def rel_class_name 70 @rel_class_name ||= association.relationship_class.name.to_s 71 end
rel_klass()
click to toggle source
# File lib/active_graph/node/reflection.rb 65 def rel_klass 66 @rel_klass ||= rel_class_name.constantize 67 end
type()
click to toggle source
# File lib/active_graph/node/reflection.rb 73 def type 74 @type ||= association.relationship_type 75 end
validate?()
click to toggle source
# File lib/active_graph/node/reflection.rb 81 def validate? 82 true 83 end