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.

Constants

Methods

#association

The association object referenced by this reflection

def association
  @association
end
#class_name

Returns the name of the target model

def class_name
  @class_name ||= association.target_class.name
end

#collection?

def collection?
  macro == :has_many
end

#initialize

def initialize(macro, name, association)
  @macro        = macro
  @name         = name
  @association  = association
end
#klass

Returns the target model

def klass
  @klass ||= class_name.constantize
end
#macro

The type of association

def macro
  @macro
end
#name

The name of the association

def name
  @name
end

#rel_class_name

def rel_class_name
  @rel_class_name ||= association.relationship_class.name.to_s
end

#rel_klass

def rel_klass
  @rel_klass ||= rel_class_name.constantize
end

#type

def type
  @type ||= association.relationship_type
end

#validate?

def validate?
  true
end