Issue #7876 has been reported by wardrop (Tom Wardrop). ---------------------------------------- Feature #7876: Add method for accessing Class from within Singleton Class https://bugs.ruby-lang.org/issues/7876 Author: wardrop (Tom Wardrop) Status: Open Priority: Normal Assignee: Category: Target version: =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
on 2013-02-18 12:00
on 2013-02-22 01:07
Issue #7876 has been updated by ko1 (Koichi Sasada). Category set to core Assignee set to matz (Yukihiro Matsumoto) Target version set to next minor ---------------------------------------- Feature #7876: Add method for accessing Class from within Singleton Class https://bugs.ruby-lang.org/issues/7876#change-36735 Author: wardrop (Tom Wardrop) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor =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
on 2013-02-22 02:52
Issue #7876 has been updated by duerst (Martin Dürst). This should be possible with Module#ancestors. Maybe not totally slick, but possible. ---------------------------------------- Feature #7876: Add method for accessing Class from within Singleton Class https://bugs.ruby-lang.org/issues/7876#change-36756 Author: wardrop (Tom Wardrop) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor =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
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.