Skip to content

Commit

Permalink
Add the Kernel#singleton_class? predicate method
Browse files Browse the repository at this point in the history
This method is a convenient way to know whether a given object is a
singleton class or not. This feature has been added in Ruby 2.1 (see
https://bugs.ruby-lang.org/issues/7609 for further information).
  • Loading branch information
robin850 committed Jul 30, 2014
1 parent d159898 commit 2e71722
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/bootstrap/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def singleton_class
Rubinius::Type.object_singleton_class self
end

def singleton_class?
!!Rubinius::Type.singleton_class_object(self)
end

def extend(*mods)
Rubinius::Type.object_singleton_class(self).include(*mods)
self
Expand Down

0 comments on commit 2e71722

Please sign in to comment.