rename AR::Model::Tag to AR::Tag - fixes #7714

This commit is contained in:
Francesco Rodriguez 2012-09-20 12:43:12 -05:00
parent 3034489500
commit a30b8d38b4
6 changed files with 19 additions and 14 deletions

@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
* Rename `ActiveRecord::Model::Tag` to `ActiveRecord::Tag`.
Fix #7714.
*Francesco Rodriguez*
* `ActiveModel::ForbiddenAttributesProtection` is included by default
in Active Record models. Check the docs of `ActiveModel::ForbiddenAttributesProtection`
for more details.

@ -6,7 +6,7 @@
module ActiveRecord
# Raised when a connection could not be obtained within the connection
# acquisition timeout period: because max connections in pool
# are in use.
# are in use.
class ConnectionTimeoutError < ConnectionNotEstablished
end
@ -417,7 +417,7 @@ def reap
# queue for a connection to become available.
#
# Raises:
# - ConnectionTimeoutError if a connection could not be acquired
# - ConnectionTimeoutError if a connection could not be acquired
def acquire_connection
if conn = @available.poll
conn
@ -567,7 +567,7 @@ def retrieve_connection_pool(klass)
class_to_pool[klass] ||= begin
until pool = pool_for(klass)
klass = klass.superclass
break unless klass < Model::Tag
break unless klass < ActiveRecord::Tag
end
class_to_pool[klass] = pool || pool_for(ActiveRecord::Model)

@ -50,7 +50,7 @@ def symbolized_sti_name
# If B < A and C < B and if A is an abstract_class then both B.base_class
# and C.base_class would return B as the answer since A is an abstract_class.
def base_class
unless self < Model::Tag
unless self < ActiveRecord::Tag
raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord"
end
@ -73,7 +73,7 @@ def base_class
# class Child < SuperClass
# self.table_name = 'the_table_i_really_want'
# end
#
#
#
# <tt>self.abstract_class = true</tt> is required to make <tt>Child<.find,.create, or any Arel method></tt> use <tt>the_table_i_really_want</tt> instead of a table called <tt>super_classes</tt>
#

@ -26,21 +26,21 @@ def #{name}; ActiveRecord::Model.#{name}; end
end
end
# <tt>ActiveRecord::Model</tt> can be included into a class to add Active Record persistence.
# This is an alternative to inheriting from <tt>ActiveRecord::Base</tt>. Example:
# This allows us to detect an ActiveRecord::Model while it's in the process of
# being included.
module Tag; end
# <tt>ActiveRecord::Model</tt> can be included into a class to add Active Record
# persistence. This is an alternative to inheriting from <tt>ActiveRecord::Base</tt>.
#
# class Post
# include ActiveRecord::Model
# end
#
module Model
extend ActiveSupport::Concern
extend ConnectionHandling
extend ActiveModel::Observing::ClassMethods
# This allows us to detect an ActiveRecord::Model while it's in the process of being included.
module Tag; end
def self.append_features(base)
base.class_eval do
include Tag

@ -40,7 +40,7 @@ def self.expand(klass, table, column, value)
#
# For polymorphic relationships, find the foreign key and type:
# PriceEstimate.where(:estimate_of => treasure)
if klass && value.class < Model::Tag && reflection = klass.reflect_on_association(column.to_sym)
if klass && value.class < ActiveRecord::Tag && reflection = klass.reflect_on_association(column.to_sym)
if reflection.polymorphic?
queries << build(table[reflection.foreign_type], value.class.base_class)
end

@ -4,8 +4,8 @@ module ActiveRecord
module ConnectionAdapters
class ConnectionHandlerTest < ActiveRecord::TestCase
def setup
@klass = Class.new { include Model::Tag }
@subklass = Class.new(@klass) { include Model::Tag }
@klass = Class.new { include ActiveRecord::Tag }
@subklass = Class.new(@klass) { include ActiveRecord::Tag }
@handler = ConnectionHandler.new
@handler.establish_connection @klass, Base.connection_pool.spec