-
-
Save havenwood/13f5a3a989283edda37e to your computer and use it in GitHub Desktop.
Works in 1.8**
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
module Yay | |
def self.included klass | |
klass.instance_eval do | |
singleton = class << self | |
self | |
end | |
singleton.send :define_method, :add_a_method do |awesome_name| | |
singleton.send :define_method, awesome_name do | |
puts 123 | |
end | |
end | |
end | |
end | |
end | |
class Foo | |
include Yay | |
add_a_method :stuff | |
end | |
Foo.stuff | |
#=> 123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment