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
class Module | |
def const_missing(const_name) | |
puts "[ModuleConstMissing] #{self} missing #{const_name}" | |
end | |
end | |
class FakeDelegator < BasicObject | |
def self.const_missing(name) | |
puts "[FakeDelegator] missing #{name}" | |
if ::Object.const_defined?(name) | |
::Object.const_get(name) | |
else | |
super if defined?(super) | |
end | |
end | |
end | |
class MyObject1 | |
File | |
NoSuch | |
end | |
puts | |
class MyObject2 < FakeDelegator | |
File | |
NoSuch | |
end |
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
[ModuleConstMissing] MyObject1 missing NoSuch | |
[FakeDelegator] missing File | |
[FakeDelegator] missing NoSuch | |
[ModuleConstMissing] MyObject2 missing NoSuch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment