Created
October 1, 2013 20:32
-
-
Save ngpestelos/6784636 to your computer and use it in GitHub Desktop.
class extension
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
# see Metaprogramming Ruby, p. 116 | |
# this will not work | |
#module MyModule | |
# def self.my_method; 'hello'; end | |
#end | |
module MyModule | |
def my_method; 'hello'; end | |
end | |
class MyClass | |
class << self | |
include MyModule | |
end | |
end | |
puts MyClass.my_method # 'hello' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment