Here’s the change to #is I’ve been contemplating. I’m thinking it
might make a good override of include actually.
class Module
def is(*mods)
mods.each do |mod|
if mod.const_defined?(:Self)
extend mod.const_get(:Self)
end
end
include(*mods)
end
end
example:
module Dog
def bark; "ruff"; end
module Self
def fleas; '. ' * rand(10).to_i; end
end
end
class Spot
is Dog
end
Spot.fleas #=> '. . . . . ’
T.