diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-02-25 09:32:29 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-02-25 09:32:29 -0800 |
commit | f7b0a857e97304a5daeb47313759b9bf0d7e2fc9 (patch) | |
tree | 81bda0d86cc1d22e3e8c50e5e852d200aec7be57 /activesupport/lib/active_support/core_ext/class/delegating_attributes.rb | |
parent | 6b12d74026808a3014f1dff34481006a96e0f18f (diff) | |
download | rails-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/delegating_attributes.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/class/delegating_attributes.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb index 19382abb76..b5785bdcd3 100644 --- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb @@ -1,6 +1,6 @@ require 'active_support/core_ext/object/blank' require 'active_support/core_ext/array/extract_options' -require 'active_support/core_ext/object/metaclass' +require 'active_support/core_ext/object/singleton_class' class Class def superclass_delegating_accessor(name, options = {}) @@ -11,9 +11,9 @@ class Class # Generate the public methods name, name=, and name? # These methods dispatch to the private _name, and _name= methods, making them # overridable - metaclass.send(:define_method, name) { send("_#{name}") } - metaclass.send(:define_method, "#{name}?") { !!send("_#{name}") } - metaclass.send(:define_method, "#{name}=") { |value| send("_#{name}=", value) } + singleton_class.send(:define_method, name) { send("_#{name}") } + singleton_class.send(:define_method, "#{name}?") { !!send("_#{name}") } + singleton_class.send(:define_method, "#{name}=") { |value| send("_#{name}=", value) } # If an instance_reader is needed, generate methods for name and name= on the # class itself, so instances will be able to see them @@ -27,12 +27,12 @@ private # inheritance behavior, without having to store the object in an instance # variable and look up the superclass chain manually. def _stash_object_in_method(object, method, instance_reader = true) - metaclass.send(:define_method, method) { object } + singleton_class.send(:define_method, method) { object } define_method(method) { object } if instance_reader end def _superclass_delegating_accessor(name, options = {}) - metaclass.send(:define_method, "#{name}=") do |value| + singleton_class.send(:define_method, "#{name}=") do |value| _stash_object_in_method(value, name, options[:instance_reader] != false) end self.send("#{name}=", nil) |