From 0b87d114bde73cddb9401d061acc1f2f4b3e1dfc Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 25 Feb 2010 10:57:29 -0800 Subject: Missed singleton_class --- .../lib/active_support/core_ext/object/singleton_class.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/object/singleton_class.rb (limited to 'activesupport') 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 -- cgit v1.2.3