Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------- Module#module_function
- module_function(symbol, ...) => self
- ------------------------------------------------------------------------
- Creates module functions for the named methods. These functions may
- be called with the module as a receiver, and also become available
- as instance methods to classes that mix in the module. Module
- functions are copies of the original, and so may be changed
- independently. The instance-method versions are made private. If
- used with no arguments, subsequently defined methods become module
- functions.
- module Mod
- def one
- "This is one"
- end
- module_function :one
- end
- class Cls
- include Mod
- def callOne
- one
- end
- end
- Mod.one #=> "This is one"
- c = Cls.new
- c.callOne #=> "This is one"
- module Mod
- def one
- "This is the new one"
- end
- end
- Mod.one #=> "This is one"
- c.callOne #=> "This is the new one"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement