Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created December 28, 2012 01:03
Show Gist options
  • Save ahoward/4393636 to your computer and use it in GitHub Desktop.
Save ahoward/4393636 to your computer and use it in GitHub Desktop.
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