Skip to content

Instantly share code, notes, and snippets.

@ngpestelos
Created October 1, 2013 20:32
Show Gist options
  • Save ngpestelos/6784636 to your computer and use it in GitHub Desktop.
Save ngpestelos/6784636 to your computer and use it in GitHub Desktop.
class extension
# 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