aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-12-28 09:46:48 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-12-28 09:46:48 -0800
commit90df0d4f687596943bda108ab0b98dd99cacd46b (patch)
treec80aaefc356f871b149567025c08ad7638542ba7 /activesupport/lib/active_support
parent5e6fc81d63837559a393c173eade281ddeb687dd (diff)
parentcdf7a6013dcea316d8a4c3336afe7037cc1a813e (diff)
downloadrails-90df0d4f687596943bda108ab0b98dd99cacd46b.tar.gz
rails-90df0d4f687596943bda108ab0b98dd99cacd46b.tar.bz2
rails-90df0d4f687596943bda108ab0b98dd99cacd46b.zip
Merge pull request #4220 from bensie/singleton-class-master
Further simplify singleton_class checking in class_attribute
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb15
1 files changed, 1 insertions, 14 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index 45bec264ff..a04445d34d 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -81,21 +81,13 @@ 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} : self.class.#{name}
+ defined?(@#{name}) ? @#{name} : singleton_class.#{name}
end
def #{name}?
@@ -107,9 +99,4 @@ class Class
attr_writer name if instance_writer
end
end
-
- private
- def singleton_class?
- !name || '' == name
- end
end