aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object')
-rw-r--r--activesupport/lib/active_support/core_ext/object/metaclass.rb13
-rw-r--r--activesupport/lib/active_support/core_ext/object/singleton_class.rb13
2 files changed, 13 insertions, 13 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/metaclass.rb b/activesupport/lib/active_support/core_ext/object/metaclass.rb
deleted file mode 100644
index 93fb0ad594..0000000000
--- a/activesupport/lib/active_support/core_ext/object/metaclass.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class Object
- # Get object's meta (ghost, eigenclass, singleton) class
- def metaclass
- class << self
- self
- end
- end
-
- # If class_eval is called on an object, add those methods to its metaclass
- def class_eval(*args, &block)
- metaclass.class_eval(*args, &block)
- end
-end
diff --git a/activesupport/lib/active_support/core_ext/object/singleton_class.rb b/activesupport/lib/active_support/core_ext/object/singleton_class.rb
new file mode 100644
index 0000000000..8dee54e71b
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/object/singleton_class.rb
@@ -0,0 +1,13 @@
+class Object
+ # Returns the object's singleton class.
+ def singleton_class
+ class << self
+ self
+ end
+ end unless respond_to?(:singleton_class)
+
+ # class_eval on an object acts like singleton_class_eval.
+ def class_eval(*args, &block)
+ singleton_class.class_eval(*args, &block)
+ end
+end