lib/singleton_class_helpers/refinement.rb
# Returns the class for which the module/class is the singleton class.
#
# It returns nil when the module/class is not a singleton class.
Returns the class for which the module/class is the singleton class.
It returns nil when the module/class is not a singleton class.
Returns the class for which the module / class is the singleton class . It returns nil when the module / class is not a singleton class .
def singleton_of
        return unless singleton_class?
        ObjectSpace.reachable_objects_from(self).find do |reachable_obj|
          reachable_obj.singleton_class == self
        end
      end
def singleton_of return unless singleton_class? ObjectSpace . reachable_objects_from ( self ) . find do | reachable_obj | reachable_obj . singleton_class == self end end
Returns the class for which the module/class is the singleton class.
Returns the class for which the module / class is the singleton class .