class Lolita::Adapter::ActiveRecord::Association

Association adapter

Attributes

adapter[R]
association[R]

Public Class Methods

new(assoc_object,adapter) click to toggle source
# File lib/lolita/adapter/active_record.rb, line 17
def initialize(assoc_object,adapter)
  @association = assoc_object
  @adapter = adapter
end

Public Instance Methods

association_key() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 34
def association_key
  @association.association_foreign_key
end
foreign_key() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 38
def foreign_key
  @association.foreign_key
end
key() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 26
def key # maybe this isn't neccessery any more
  if @association.macro == :has_and_belongs_to_many || through?
    association_key
  else
    @association.foreign_key
  end
end
macro() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 58
def macro
  convertator = {
    :has_many => :many, :has_one => :one, :belongs_to => :one,
    :has_and_belongs_to_many => :many_to_many
  }
  convertator[@association.macro]
end
method_missing(method, *args, &block) click to toggle source
# File lib/lolita/adapter/active_record.rb, line 22
def method_missing(method, *args, &block)
  @association.send(method,*args,&block)
end
native_macro() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 54
def native_macro
  @association.macro
end
polymorphic?() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 50
def polymorphic?
  @association.options[:polymorphic]
end
through() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 42
def through
  @association.options[:through]
end
through?() click to toggle source
# File lib/lolita/adapter/active_record.rb, line 46
def through?
  @association.options.has_key?(:through)
end