Skip to content

Instantly share code, notes, and snippets.

@ryanlecompte
Created May 2, 2011 20:40
Show Gist options
  • Save ryanlecompte/952316 to your computer and use it in GitHub Desktop.
Save ryanlecompte/952316 to your computer and use it in GitHub Desktop.
Example of flattening scopes
module M
def self.included(base)
base.class_eval do
singleton_class = (class << self; self; end)
singleton_class.send(:define_method, :foo) do
puts "in foo! base is #{base}"
end
end
end
end
class C
include M
end
C.foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment