Skip to content

Commit

Permalink
Missed singleton_class
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Feb 25, 2010
1 parent c7f9e8c commit 0b87d11
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 0b87d11

Please sign in to comment.