Project

General

Profile

ActionsLike0

Feature #7876

open

Add method for accessing Class from within Singleton Class

Added by wardrop (Tom Wardrop) about 12 years ago. Updated about 1 year ago.

Status:
Assigned
Target version:
-
[ruby-core:52436]

Description

=begin
I'm quite surprised I haven't run into this sooner, but I seem to have just discovered that there's no means by which you can access the outer Class object once inside the context of the Singleton Class. Take the following example; how would I get a reference to (({Test})) from within the singleton?

class Test
class << self
# How do I get a reference to Test from here?
end
end

I assume the answer is that there is no reliable way, hence the reason for this request. Could we add a method to the singleton class that allows access to the "outer" class, e.g.

class Test
class << self
self.outerclass
end
end

Thoughts?
=end

Updated by ko1 (Koichi Sasada) about 12 years ago

  • Category set to core
  • Assignee set to matz (Yukihiro Matsumoto)
  • Target version set to 2.6
#3

Updated by naruse (Yui NARUSE) over 7 years ago

  • Target version deleted (2.6)
#4

Updated by hsbt (Hiroshi SHIBATA) about 1 year ago

  • Status changed from Open to Assigned
ActionsLike0

Also available in: Atom PDF