Feature #7609

Class#singleton_class?

Added by Nobuyoshi Nakada over 1 year ago. Updated 9 months ago.

[ruby-core:51087]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:core
Target version:next minor

Description

Related to #7554, there is no way to tell the called method is a singleton method or an ordinary method.

singleton_class_p.patch Magnifier (1.34 KB) Nobuyoshi Nakada, 12/23/2012 05:48 PM

Associated revisions

Revision 42449
Added by Nobuyoshi Nakada 9 months ago

object.c: Module#singleton_class?

  • object.c (rbmodsingletonp): new method Module#singletonclass? to return whether the receiver is a singleton class or not. [Feature #7609]

History

#1 Updated by Marc-Andre Lafortune over 1 year ago

Moving to Feature requests.

Just curious about use case?

Also, can be hacked in Ruby already...

class Class
  def singleton_class?
    Class.new(self) && true rescue false
  end
end

#2 Updated by Marc-Andre Lafortune over 1 year ago

  • Tracker changed from Bug to Feature

#3 Updated by Yukihiro Matsumoto over 1 year ago

  • Assignee set to Nobuyoshi Nakada
  • Target version set to next minor

OK.

#4 Updated by Nobuyoshi Nakada 9 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r42449.
Nobuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


object.c: Module#singleton_class?

  • object.c (rbmodsingletonp): new method Module#singletonclass? to return whether the receiver is a singleton class or not. [Feature #7609]

Also available in: Atom PDF