Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created September 18, 2012 19:17
Show Gist options
  • Save havenwood/13f5a3a989283edda37e to your computer and use it in GitHub Desktop.
Save havenwood/13f5a3a989283edda37e to your computer and use it in GitHub Desktop.
Works in 1.8**
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