Skip to content

Instantly share code, notes, and snippets.

@stephan-buckmaster
Created October 31, 2023 15:49
Show Gist options
  • Save stephan-buckmaster/cead033f788673f78ad2bf0433395e20 to your computer and use it in GitHub Desktop.
Save stephan-buckmaster/cead033f788673f78ad2bf0433395e20 to your computer and use it in GitHub Desktop.
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