Skip to content

Instantly share code, notes, and snippets.

@kohsuke
Created August 25, 2011 14:17
Show Gist options
  • Save kohsuke/1170770 to your computer and use it in GitHub Desktop.
Save kohsuke/1170770 to your computer and use it in GitHub Desktop.
module M
def self.included(cls)
super(cls)
puts "xyz"
if cls.class == Module
cls.extend(M)
else
# Quote of the day
# Kohsuke: "Did I just avoid the harm of eval?"
# NaHi: "No, this is actually worse"
cls.module_eval do
def self.inherited(p)
puts "#{self} was subtyped by #{p}"
end
end
end
end
end
class Alice
include M
end
class Bob < Alice
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment