Skip to content

Instantly share code, notes, and snippets.

@sixtyfive
Last active May 21, 2019 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixtyfive/50b71960530bb7fa25ec984eef46e82d to your computer and use it in GitHub Desktop.
Save sixtyfive/50b71960530bb7fa25ec984eef46e82d to your computer and use it in GitHub Desktop.
#!/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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment