Skip to content

Commit

Permalink
Merge pull request #11282 from arunagw/deprecation-removed-attribute-…
Browse files Browse the repository at this point in the history
…missing-activerecord

Remove deprecated `attribute_missing`.
  • Loading branch information
senny committed Jul 15, 2013
2 parents ea7620d + 0d4075f commit d7a1f98
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,3 +1,7 @@
* Remove deprecation warning from `attribute_missing` for attributes that are columns.

*Arun Agrawal*

* Remove extra decrement of transaction deep level. * Remove extra decrement of transaction deep level.


Fixes: #4566 Fixes: #4566
Expand Down
14 changes: 0 additions & 14 deletions activerecord/lib/active_record/attribute_methods.rb
Expand Up @@ -176,20 +176,6 @@ def method_missing(method, *args, &block) # :nodoc:
end end
end end


def attribute_missing(match, *args, &block) # :nodoc:
if self.class.columns_hash[match.attr_name]
ActiveSupport::Deprecation.warn(
"The method `#{match.method_name}', matching the attribute `#{match.attr_name}' has " \
"dispatched through method_missing. This shouldn't happen, because `#{match.attr_name}' " \
"is a column of the table. If this error has happened through normal usage of Active " \
"Record (rather than through your own code or external libraries), please report it as " \
"a bug."
)
end

super
end

# A Person object with a name attribute can ask <tt>person.respond_to?(:name)</tt>, # A Person object with a name attribute can ask <tt>person.respond_to?(:name)</tt>,
# <tt>person.respond_to?(:name=)</tt>, and <tt>person.respond_to?(:name?)</tt> # <tt>person.respond_to?(:name=)</tt>, and <tt>person.respond_to?(:name?)</tt>
# which will all return +true+. It also define the attribute methods if they have # which will all return +true+. It also define the attribute methods if they have
Expand Down
15 changes: 0 additions & 15 deletions activerecord/test/cases/attribute_methods_test.rb
Expand Up @@ -759,21 +759,6 @@ def test_instance_method_should_be_defined_on_the_base_class
assert subklass.method_defined?(:id), "subklass is missing id method" assert subklass.method_defined?(:id), "subklass is missing id method"
end end


def test_dispatching_column_attributes_through_method_missing_deprecated
Topic.define_attribute_methods

topic = Topic.new(:id => 5)
topic.id = 5

topic.method(:id).owner.send(:undef_method, :id)

assert_deprecated do
assert_equal 5, topic.id
end
ensure
Topic.undefine_attribute_methods
end

def test_read_attribute_with_nil_should_not_asplode def test_read_attribute_with_nil_should_not_asplode
assert_equal nil, Topic.new.read_attribute(nil) assert_equal nil, Topic.new.read_attribute(nil)
end end
Expand Down

0 comments on commit d7a1f98

Please sign in to comment.