class SampleModels::Model::Association

Public Class Methods

new(assoc) click to toggle source
# File lib/sample_models/model.rb, line 56
def initialize(assoc)
  @assoc = assoc
end

Public Instance Methods

__getobj__() click to toggle source
# File lib/sample_models/model.rb, line 60
def __getobj__
  @assoc
end
belongs_to?() click to toggle source
# File lib/sample_models/model.rb, line 64
def belongs_to?
  @assoc.macro == :belongs_to
end
foreign_key() click to toggle source
# File lib/sample_models/model.rb, line 68
def foreign_key
  if @assoc.respond_to?(:foreign_key)
    @assoc.foreign_key
  else
    @assoc.primary_key_name
  end
end
foreign_type() click to toggle source
# File lib/sample_models/model.rb, line 76
def foreign_type
  if @assoc.respond_to?(:foreign_type)
    @assoc.foreign_type
  else
    @assoc.instance_variable_get(:@options)[:foreign_type]
  end
end
has_many?() click to toggle source
# File lib/sample_models/model.rb, line 84
def has_many?
  @assoc.macro == :has_many
end
polymorphic?() click to toggle source
# File lib/sample_models/model.rb, line 88
def polymorphic?
  @assoc.options[:polymorphic]
end