Skip to content

Instantly share code, notes, and snippets.

@lleirborras
Created July 29, 2010 10:21
Show Gist options
  • Save lleirborras/497789 to your computer and use it in GitHub Desktop.
Save lleirborras/497789 to your computer and use it in GitHub Desktop.
module Mod
def self.included(base)
base.class_eval do
puts "Included in #{base}"
p ObjectSpace.each_object(Class).sort{|a,b| a.name <=> b.name}.select{|a| a.superclass == Person}.uniq.size
end
end
end
class Person
end
class Foo < Person
include Mod
end
class Bar < Person
include Mod
end
#Output:
#Included in Foo
#1
#Included in Bar
#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment