aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class/attribute.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-02-25 09:32:29 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2010-02-25 09:32:29 -0800
commitf7b0a857e97304a5daeb47313759b9bf0d7e2fc9 (patch)
tree81bda0d86cc1d22e3e8c50e5e852d200aec7be57 /activesupport/lib/active_support/core_ext/class/attribute.rb
parent6b12d74026808a3014f1dff34481006a96e0f18f (diff)
downloadrails-f7b0a857e97304a5daeb47313759b9bf0d7e2fc9.tar.gz
rails-f7b0a857e97304a5daeb47313759b9bf0d7e2fc9.tar.bz2
rails-f7b0a857e97304a5daeb47313759b9bf0d7e2fc9.zip
Use Object#singleton_class instead of #metaclass. Prefer Ruby's choice.
Diffstat (limited to 'activesupport/lib/active_support/core_ext/class/attribute.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index d74219cb93..1bd39a9349 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/object/metaclass'
+require 'active_support/core_ext/object/singleton_class'
require 'active_support/core_ext/module/delegation'
class Class
@@ -25,11 +25,12 @@ class Class
#
# Subclass.setting? # => false
def class_attribute(*attrs)
+ s = singleton_class
attrs.each do |attr|
- metaclass.send(:define_method, attr) { }
- metaclass.send(:define_method, "#{attr}?") { !!send(attr) }
- metaclass.send(:define_method, "#{attr}=") do |value|
- metaclass.send(:define_method, attr) { value }
+ s.send(:define_method, attr) { }
+ s.send(:define_method, "#{attr}?") { !!send(attr) }
+ s.send(:define_method, "#{attr}=") do |value|
+ singleton_class.send(:define_method, attr) { value }
end
end
end