-
-
Save ahoward/4393636 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Mixin | |
Code = proc do | |
a_class_level_method(self.name) | |
end | |
def Mixin.included(other) | |
super | |
ensure | |
other.module_eval(&Code) | |
end | |
end | |
class C | |
class << self | |
attr_accessor :it | |
def a_class_level_method(value) | |
@it = value | |
end | |
end | |
end | |
class B < C | |
end | |
C.send(:include, Mixin) | |
B.send(:include, Mixin) | |
p C.it | |
p B.it | |
__END__ | |
"C" | |
"B" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment