Created
May 2, 2011 20:40
-
-
Save ryanlecompte/952316 to your computer and use it in GitHub Desktop.
Example of flattening scopes
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 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