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.
- #association
The association object referenced by this reflection
ruby
- def association
@association
end
- #class_name
Returns the name of the target model
ruby
- def class_name
@class_name ||= association.target_class.name
end
#collection?
ruby
- def collection?
macro == :has_many
end
#initialize
ruby
- def initialize(macro, name, association)
@macro = macro @name = name @association = association
end
- #klass
Returns the target model
ruby
- def klass
@klass ||= class_name.constantize
end
- #macro
The type of association
ruby
- def macro
@macro
end
- #name
The name of the association
ruby
- def name
@name
end
#rel_class_name
ruby
- def rel_class_name
@rel_class_name ||= association.relationship_class.name.to_s
end
#rel_klass
ruby
- def rel_klass
@rel_klass ||= rel_class_name.constantize
end
#type
ruby
- def type
@type ||= association.relationship_type
end
#validate?
ruby
- def validate?
true
end