Skip to content

Instantly share code, notes, and snippets.

@Narnach
Forked from samaaron/gist:37031
Created December 17, 2008 14:28
Show Gist options
  • Save Narnach/37062 to your computer and use it in GitHub Desktop.
Save Narnach/37062 to your computer and use it in GitHub Desktop.
module A
def hi(*list)
singleton = class << self; self; end
list.each do |l|
singleton.send(:define_method, l) do
puts l
end
end
end
end
class B
extend A
end
B.hi(:sam, :toddy)
B.sam # => prints "sam"
B.new.sam # => fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment