Permalink
Browse files

Missed singleton_class

  • Loading branch information...
jeremy committed Feb 25, 2010
1 parent 5b4e7c3 commit 3a3fa7f817acf7478c5a363d7826a23655812dea
Showing with 13 additions and 0 deletions.
  1. +13 −0 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

0 comments on commit 3a3fa7f

Please sign in to comment.