From 89978f10afbad3f856e2959a811bed1982715408 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 5 Apr 2010 12:15:08 -0700 Subject: moves Object#singleton_class to Kernel#singleton_class to match Ruby also there, same for #class_eval to simplify, and adds coverage for class_eval --- .../lib/active_support/core_ext/kernel/singleton_class.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/kernel/singleton_class.rb (limited to 'activesupport/lib/active_support/core_ext/kernel') diff --git a/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb b/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb new file mode 100644 index 0000000000..33612155fb --- /dev/null +++ b/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb @@ -0,0 +1,13 @@ +module Kernel + # Returns the object's singleton class. + def singleton_class + class << self + self + end + end unless respond_to?(:singleton_class) # exists in 1.9.2 + + # class_eval on an object acts like singleton_class.class_eval. + def class_eval(*args, &block) + singleton_class.class_eval(*args, &block) + end +end -- cgit v1.2.3