Created
October 31, 2023 15:49
-
-
Save stephan-buckmaster/cead033f788673f78ad2bf0433395e20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GetConstNames | |
def my_const_names | |
Module.constants.select { |c| Module.const_get(c).object_id == self.object_id} | |
end | |
end | |
class ABC | |
include GetConstNames | |
end | |
EFG = ABC.new | |
puts EFG.my_const_names | |
# >> EFG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment