Skip to content

Instantly share code, notes, and snippets.

@jackjennings
Last active March 27, 2025 01:59
Show Gist options
  • Save jackjennings/8a02f30fb15a6fa9be9e221fe92e12d7 to your computer and use it in GitHub Desktop.
Save jackjennings/8a02f30fb15a6fa9be9e221fe92e12d7 to your computer and use it in GitHub Desktop.
Object.class_eval do
def self.const_added(const_name)
super
if !const_name.to_s.upcase!
self.private_constant const_name
end
end
end
class Foo
BAR = 1
end
puts Foo::BAR
# => private constant Foo::BAR referenced (NameError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment