module ActiveRecord::Core::ClassMethods
Public Instance Methods
===(object)
click to toggle source
Overwrite the default class equality method to provide support for association proxies.
# File lib/active_record/core.rb, line 262 def ===(object) object.is_a?(self) end
allocate()
click to toggle source
Calls superclass method
# File lib/active_record/core.rb, line 153 def allocate define_attribute_methods super end
generated_association_methods()
click to toggle source
# File lib/active_record/core.rb, line 235 def generated_association_methods @generated_association_methods ||= begin mod = const_set(:GeneratedAssociationMethods, Module.new) private_constant :GeneratedAssociationMethods include mod mod end end
inspect()
click to toggle source
Returns a string like 'Post(id:integer, title:string, body:text)'
Calls superclass method
# File lib/active_record/core.rb, line 246 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 = attribute_types.map { |name, type| "#{name}: #{type.type}" } * ", " "#{super}(#{attr_list})" else "#{super}(Table doesn't exist)" end end
Private Instance Methods
cached_find_by_statement(key, &block)
click to toggle source
# File lib/active_record/core.rb, line 300 def cached_find_by_statement(key, &block) cache = @find_by_statement_cache[connection.prepared_statements] cache[key] || cache.synchronize { cache[key] ||= StatementCache.create(connection, &block) } end
relation()
click to toggle source
# File lib/active_record/core.rb, line 307 def relation relation = Relation.create(self, arel_table, predicate_builder) if finder_needs_type_condition? && !ignore_default_scope? relation.where(type_condition).create_with(inheritance_column.to_s => sti_name) else relation end end
table_metadata()
click to toggle source
# File lib/active_record/core.rb, line 317 def table_metadata TableMetadata.new(self, arel_table) end