diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-28 18:27:25 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-28 18:27:41 +0000 |
commit | 9bae926ff254ae202308af949109e110aec7c3b9 (patch) | |
tree | 9f2b0dfd3ce88fff37498ef37ee616268bc19e5c | |
parent | 6e5b98e9102373957d748aa084f625d2d56e02ff (diff) | |
download | rails-9bae926ff254ae202308af949109e110aec7c3b9.tar.gz rails-9bae926ff254ae202308af949109e110aec7c3b9.tar.bz2 rails-9bae926ff254ae202308af949109e110aec7c3b9.zip |
Revert "Merge pull request #4220 from bensie/singleton-class-master"
This reverts commit 90df0d4f687596943bda108ab0b98dd99cacd46b, reversing
changes made to 5e6fc81d63837559a393c173eade281ddeb687dd.
Reason: build breakage
-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 |