123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::Core::ClassMethods

Relationships & Source Files
Defined in: activerecord/lib/active_record/core.rb

Instance Method Summary

Instance Method Details

#===(object)

Overwrite the default class equality method to provide support for association proxies.

[ GitHub ]

  
# File 'activerecord/lib/active_record/core.rb', line 228

def ===(object)
  object.is_a?(self)
end

#allocate

[ GitHub ]

  
# File 'activerecord/lib/active_record/core.rb', line 112

def allocate
  define_attribute_methods
  super
end

#generated_association_methods

[ GitHub ]

  
# File 'activerecord/lib/active_record/core.rb', line 203

def generated_association_methods
  @generated_association_methods ||= begin
    mod = const_set(:GeneratedAssociationMethods, Module.new)
    include mod
    mod
  end
end

#inspect

Returns a string like 'Post(id:integer, title:string, body:text)'

[ GitHub ]

  
# File 'activerecord/lib/active_record/core.rb', line 212

def inspect
  if self == Base
    super
  elsif abstract_class?
    "#{super}(abstract)"
  elsif !connected?
    "#{super} (call '#{super}.connection' to establish a connection)"
  elsif table_exists?
    attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', '
    "#{super}(#{attr_list})"
  else
    "#{super}(Table doesn't exist)"
  end
end