diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-28 18:45:28 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-28 18:45:28 +0000 |
commit | bbafe73d8fe718cff1b8e6ca6b490c4b7e0b40c5 (patch) | |
tree | 32825c0ae04fcf642cf688c1d186d72dd9bc65a6 /activesupport/lib/active_support/core_ext/class | |
parent | df3701872d6c97ff49943aea30761b47e60fa9fe (diff) | |
download | rails-bbafe73d8fe718cff1b8e6ca6b490c4b7e0b40c5.tar.gz rails-bbafe73d8fe718cff1b8e6ca6b490c4b7e0b40c5.tar.bz2 rails-bbafe73d8fe718cff1b8e6ca6b490c4b7e0b40c5.zip |
Revert "Further simplify singleton_class checking in class_attribute"
This reverts commit 520918aad9b84eee807eb42fcb32f57c152d50e0.
Reason: build failure
Diffstat (limited to 'activesupport/lib/active_support/core_ext/class')
-rw-r--r-- | activesupport/lib/active_support/core_ext/class/attribute.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index a04445d34d..45bec264ff 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -81,13 +81,21 @@ class Class define_method(:#{name}) { val } end + if singleton_class? + class_eval do + remove_possible_method(:#{name}) + def #{name} + defined?(@#{name}) ? @#{name} : singleton_class.#{name} + end + end + end val end if instance_reader remove_possible_method :#{name} def #{name} - defined?(@#{name}) ? @#{name} : singleton_class.#{name} + defined?(@#{name}) ? @#{name} : self.class.#{name} end def #{name}? @@ -99,4 +107,9 @@ class Class attr_writer name if instance_writer end end + + private + def singleton_class? + !name || '' == name + end end |