Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove deprecated set and original methods for table_name, primary_ke…

…y, etc
  • Loading branch information...
commit 9add7608f1acaa68b025470e7a38901d7e6161ca 1 parent abdb105
@lest lest authored
View
9 activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -80,10 +80,6 @@ def get_primary_key(base_name) #:nodoc:
end
end
- def original_primary_key #:nodoc:
- deprecated_original_property_getter :primary_key
- end
-
# Sets the name of the primary key column.
#
# class Project < ActiveRecord::Base
@@ -103,11 +99,6 @@ def primary_key=(value)
@primary_key = value && value.to_s
@quoted_primary_key = nil
end
-
- def set_primary_key(value = nil, &block) #:nodoc:
- deprecated_property_setter :primary_key, value, block
- @quoted_primary_key = nil
- end
end
end
end
View
10 activerecord/lib/active_record/locking/optimistic.rb
@@ -144,26 +144,18 @@ def locking_enabled?
lock_optimistically && columns_hash[locking_column]
end
+ # Set the column to use for optimistic locking. Defaults to +lock_version+.
def locking_column=(value)
@original_locking_column = @locking_column if defined?(@locking_column)
@locking_column = value.to_s
end
- # Set the column to use for optimistic locking. Defaults to +lock_version+.
- def set_locking_column(value = nil, &block)
- deprecated_property_setter :locking_column, value, block
- end
-
# The version column used for optimistic locking. Defaults to +lock_version+.
def locking_column
reset_locking_column unless defined?(@locking_column)
@locking_column
end
- def original_locking_column #:nodoc:
- deprecated_original_property_getter :locking_column
- end
-
# Quote the column name used for optimistic locking.
def quoted_locking_column
connection.quote_column_name(locking_column)
View
55 activerecord/lib/active_record/model_schema.rb
@@ -105,10 +105,6 @@ def table_name
@table_name
end
- def original_table_name #:nodoc:
- deprecated_original_property_getter :table_name
- end
-
# Sets the table name explicitly. Example:
#
# class Project < ActiveRecord::Base
@@ -125,13 +121,6 @@ def table_name=(value)
@relation = Relation.new(self, arel_table)
end
- def set_table_name(value = nil, &block) #:nodoc:
- deprecated_property_setter :table_name, value, block
- @quoted_table_name = nil
- @arel_table = nil
- @relation = Relation.new(self, arel_table)
- end
-
# Returns a quoted version of the table name, used to construct SQL statements.
def quoted_table_name
@quoted_table_name ||= connection.quote_table_name(table_name)
@@ -161,20 +150,12 @@ def inheritance_column
end
end
- def original_inheritance_column #:nodoc:
- deprecated_original_property_getter :inheritance_column
- end
-
# Sets the value of inheritance_column
def inheritance_column=(value)
@original_inheritance_column = inheritance_column
@inheritance_column = value.to_s
end
- def set_inheritance_column(value = nil, &block) #:nodoc:
- deprecated_property_setter :inheritance_column, value, block
- end
-
def sequence_name
if base_class == self
@sequence_name ||= reset_sequence_name
@@ -183,10 +164,6 @@ def sequence_name
end
end
- def original_sequence_name #:nodoc:
- deprecated_original_property_getter :sequence_name
- end
-
def reset_sequence_name #:nodoc:
self.sequence_name = connection.default_sequence_name(table_name, primary_key)
end
@@ -210,10 +187,6 @@ def sequence_name=(value)
@sequence_name = value.to_s
end
- def set_sequence_name(value = nil, &block) #:nodoc:
- deprecated_property_setter :sequence_name, value, block
- end
-
# Indicates whether the table associated with this class exists
def table_exists?
connection.schema_cache.table_exists?(table_name)
@@ -329,34 +302,6 @@ def compute_table_name
base.table_name
end
end
-
- def deprecated_property_setter(property, value, block)
- if block
- ActiveSupport::Deprecation.warn(
- "Calling set_#{property} is deprecated. If you need to lazily evaluate " \
- "the #{property}, define your own `self.#{property}` class method. You can use `super` " \
- "to get the default #{property} where you would have called `original_#{property}`."
- )
-
- define_attr_method property, value, false, &block
- else
- ActiveSupport::Deprecation.warn(
- "Calling set_#{property} is deprecated. Please use `self.#{property} = 'the_name'` instead."
- )
-
- define_attr_method property, value, false
- end
- end
-
- def deprecated_original_property_getter(property)
- ActiveSupport::Deprecation.warn("original_#{property} is deprecated. Define self.#{property} and call super instead.")
-
- if !instance_variable_defined?("@original_#{property}") && respond_to?("reset_#{property}")
- send("reset_#{property}")
- else
- instance_variable_get("@original_#{property}")
- end
- end
end
end
end
View
161 activerecord/test/cases/base_test.rb
@@ -1383,17 +1383,6 @@ def test_reload_with_exclusive_scope
assert_equal dev, dev.reload
end
- def test_set_table_name_with_value
- k = Class.new( ActiveRecord::Base )
- k.table_name = "foo"
- assert_equal "foo", k.table_name
-
- assert_deprecated do
- k.set_table_name "bar"
- end
- assert_equal "bar", k.table_name
- end
-
def test_switching_between_table_name
assert_difference("GoodJoke.count") do
Joke.table_name = "cold_jokes"
@@ -1416,17 +1405,6 @@ def test_quoted_table_name_after_set_table_name
assert_equal klass.connection.quote_table_name("bar"), klass.quoted_table_name
end
- def test_set_table_name_with_block
- k = Class.new( ActiveRecord::Base )
- assert_deprecated do
- k.set_table_name "foo"
- k.set_table_name do
- ActiveSupport::Deprecation.silence { original_table_name } + "ks"
- end
- end
- assert_equal "fooks", k.table_name
- end
-
def test_set_table_name_with_inheritance
k = Class.new( ActiveRecord::Base )
def k.name; "Foo"; end
@@ -1434,145 +1412,6 @@ def k.table_name; super + "ks"; end
assert_equal "foosks", k.table_name
end
- def test_original_table_name
- k = Class.new(ActiveRecord::Base)
- def k.name; "Foo"; end
- k.table_name = "bar"
-
- assert_deprecated do
- assert_equal "foos", k.original_table_name
- end
-
- k = Class.new(ActiveRecord::Base)
- k.table_name = "omg"
- k.table_name = "wtf"
-
- assert_deprecated do
- assert_equal "omg", k.original_table_name
- end
- end
-
- def test_set_primary_key_with_value
- k = Class.new( ActiveRecord::Base )
- k.primary_key = "foo"
- assert_equal "foo", k.primary_key
-
- assert_deprecated do
- k.set_primary_key "bar"
- end
- assert_equal "bar", k.primary_key
- end
-
- def test_set_primary_key_with_block
- k = Class.new( ActiveRecord::Base )
- k.primary_key = 'id'
-
- assert_deprecated do
- k.set_primary_key do
- "sys_" + ActiveSupport::Deprecation.silence { original_primary_key }
- end
- end
- assert_equal "sys_id", k.primary_key
- end
-
- def test_original_primary_key
- k = Class.new(ActiveRecord::Base)
- def k.name; "Foo"; end
- k.table_name = "posts"
- k.primary_key = "bar"
-
- assert_deprecated do
- assert_equal "id", k.original_primary_key
- end
-
- k = Class.new(ActiveRecord::Base)
- k.primary_key = "omg"
- k.primary_key = "wtf"
-
- assert_deprecated do
- assert_equal "omg", k.original_primary_key
- end
- end
-
- def test_set_inheritance_column_with_value
- k = Class.new( ActiveRecord::Base )
- k.inheritance_column = "foo"
- assert_equal "foo", k.inheritance_column
-
- assert_deprecated do
- k.set_inheritance_column "bar"
- end
- assert_equal "bar", k.inheritance_column
- end
-
- def test_set_inheritance_column_with_block
- k = Class.new( ActiveRecord::Base )
- assert_deprecated do
- k.set_inheritance_column do
- ActiveSupport::Deprecation.silence { original_inheritance_column } + "_id"
- end
- end
- assert_equal "type_id", k.inheritance_column
- end
-
- def test_original_inheritance_column
- k = Class.new(ActiveRecord::Base)
- def k.name; "Foo"; end
- k.inheritance_column = "omg"
-
- assert_deprecated do
- assert_equal "type", k.original_inheritance_column
- end
- end
-
- def test_set_sequence_name_with_value
- k = Class.new( ActiveRecord::Base )
- k.sequence_name = "foo"
- assert_equal "foo", k.sequence_name
-
- assert_deprecated do
- k.set_sequence_name "bar"
- end
- assert_equal "bar", k.sequence_name
- end
-
- def test_set_sequence_name_with_block
- k = Class.new( ActiveRecord::Base )
- k.table_name = "projects"
- orig_name = k.sequence_name
- return skip "sequences not supported by db" unless orig_name
-
- assert_deprecated do
- k.set_sequence_name do
- ActiveSupport::Deprecation.silence { original_sequence_name } + "_lol"
- end
- end
- assert_equal orig_name + "_lol", k.sequence_name
- end
-
- def test_original_sequence_name
- k = Class.new(ActiveRecord::Base)
- k.table_name = "projects"
- orig_name = k.sequence_name
- return skip "sequences not supported by db" unless orig_name
-
- k = Class.new(ActiveRecord::Base)
- k.table_name = "projects"
- k.sequence_name = "omg"
-
- assert_deprecated do
- assert_equal orig_name, k.original_sequence_name
- end
-
- k = Class.new(ActiveRecord::Base)
- k.table_name = "projects"
- k.sequence_name = "omg"
- k.sequence_name = "wtf"
- assert_deprecated do
- assert_equal "omg", k.original_sequence_name
- end
- end
-
def test_sequence_name_with_abstract_class
ak = Class.new(ActiveRecord::Base)
ak.abstract_class = true
View
42 activerecord/test/cases/locking_test.rb
@@ -226,48 +226,6 @@ def test_update_without_attributes_does_not_only_update_lock_version
end
end
-class SetLockingColumnTest < ActiveRecord::TestCase
- def test_set_set_locking_column_with_value
- k = Class.new( ActiveRecord::Base )
- k.locking_column = "foo"
- assert_equal "foo", k.locking_column
-
- assert_deprecated do
- k.set_locking_column "bar"
- end
- assert_equal "bar", k.locking_column
- end
-
- def test_set_locking_column_with_block
- k = Class.new( ActiveRecord::Base )
- k.locking_column = 'foo'
-
- assert_deprecated do
- k.set_locking_column do
- "lock_" + ActiveSupport::Deprecation.silence { original_locking_column }
- end
- end
- assert_equal "lock_foo", k.locking_column
- end
-
- def test_original_locking_column
- k = Class.new(ActiveRecord::Base)
- k.locking_column = "bar"
-
- assert_deprecated do
- assert_equal ActiveRecord::Locking::Optimistic::ClassMethods::DEFAULT_LOCKING_COLUMN, k.original_locking_column
- end
-
- k = Class.new(ActiveRecord::Base)
- k.locking_column = "omg"
- k.locking_column = "wtf"
-
- assert_deprecated do
- assert_equal "omg", k.original_locking_column
- end
- end
-end
-
class OptimisticLockingWithSchemaChangeTest < ActiveRecord::TestCase
fixtures :people, :legacy_things, :references
Please sign in to comment.
Something went wrong with that request. Please try again.