aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorAleksandr Zykov <alexandrz@gmail.com>2012-07-29 22:33:39 +0600
committerAleksandr Zykov <alexandrz@gmail.com>2012-07-29 22:33:39 +0600
commitd59208d7032e2be855a89ad8d4685cc08dd7cdb3 (patch)
tree5acc57ad511c9c794fe97215f4932c068a7a6053 /activesupport/lib/active_support
parent1f870a2c5911b2eec519062486a74a725e924b3d (diff)
downloadrails-d59208d7032e2be855a89ad8d4685cc08dd7cdb3.tar.gz
rails-d59208d7032e2be855a89ad8d4685cc08dd7cdb3.tar.bz2
rails-d59208d7032e2be855a89ad8d4685cc08dd7cdb3.zip
DRY class_attribute code
Diffstat (limited to 'activesupport/lib/active_support')
-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