aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
diff options
context:
space:
mode:
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.rb12
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)