Last active
May 21, 2019 14:37
-
-
Save sixtyfive/c0ff35bb1a8b439e02fcde4778ce55ab to your computer and use it in GitHub Desktop.
For future reference
This file contains hidden or 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
#!/usr/bin/env ruby | |
module MyModule | |
module MyHelper | |
module_function def helpermethod | |
puts "helpermethod" | |
end | |
end | |
private_constant :MyHelper | |
def modmethod | |
MyHelper.helpermethod | |
end | |
end | |
class MyClass | |
include MyModule | |
# include MyHelper # works (well, such is life) | |
def initialize | |
# modmethod # works | |
# modmethod # works | |
# helpermethod # works (*shrug*) | |
end | |
end | |
myobj = MyClass.new | |
myobj.modmethod # works (good) | |
# myobj.helpermethod # fails (good) | |
# MyClass::MyHelper # fails (good) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment