class ActiveFedora::Reflection::MacroReflection

def belongs_to?

Returns +true+ if +self+ is a +belongs_to+ reflection.
def belongs_to?
  macro == :belongs_to
end

def build_association(*options)

be passed to the class's constructor.
Returns a new, unsaved instance of the associated class. +options+ will
def build_association(*options)
  klass.new(*options)
end

def class_name

has_many :clients returns 'Client'

Returns the class name for the macro.
def class_name
  @class_name ||= options[:class_name] || derive_class_name
end

def collection?

+has_and_belongs_to_many+, +false+ otherwise.
association. Returns +true+ if the +macro+ is either +has_many+ or
Returns whether or not this association reflection is for a collection
def collection?
  @collection
end

def derive_class_name

def derive_class_name
  class_name = name.to_s.camelize
  class_name = class_name.singularize if collection?
  class_name
end

def derive_foreign_key

def derive_foreign_key
  if belongs_to?
    "#{name}_id"
  elsif has_and_belongs_to_many?
    "#{name.to_s.singularize}_ids"
  elsif options[:as]
    "#{options[:as]}_id"
  elsif inverse_of && inverse_of.collection?
    "#{options[:inverse_of].to_s.singularize}_ids"
  else
    # This works well if this is a has_many that is the inverse of a belongs_to, but it isn't correct for a has_many that is the invers of a has_and_belongs_to_many
    active_fedora.name.foreign_key
  end
end

def has_and_belongs_to_many?

def has_and_belongs_to_many?
  macro == :has_and_belongs_to_many
end

def has_many?

def has_many?
  macro == :has_many
end

def initialize(macro, name, options, active_fedora)

def initialize(macro, name, options, active_fedora)
  @macro, @name, @options, @active_fedora = macro, name, options, active_fedora
  @automatic_inverse_of = nil
end

def klass

instead. This allows plugins to hook into association object creation.
a new association object. Use +build_association+ or +create_association+
Note: Do not call +klass.new+ or +klass.create+ to instantiate

# => Book
Author.reflect_on_association(:books).klass

end
has_many :books
class Author < ActiveRecord::Base

Returns the target association's class.
def klass
  @klass ||= class_name.constantize
end