aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index 7b6f8ab0a1..da0a12136c 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -79,14 +79,12 @@ class Class
def self.#{name}=(val)
singleton_class.class_eval do
- remove_possible_method(:#{name})
- define_method(:#{name}) { val }
+ redefine_method(:#{name}) { val }
end
if singleton_class?
class_eval do
- remove_possible_method(:#{name})
- def #{name}
+ redefine_method(:#{name}) do
defined?(@#{name}) ? @#{name} : singleton_class.#{name}
end
end
@@ -95,8 +93,7 @@ class Class
end
if instance_reader
- remove_possible_method :#{name}
- def #{name}
+ redefine_method(:#{name}) do
defined?(@#{name}) ? @#{name} : self.class.#{name}
end