[Nitro] Small inheritor issue
TRANS
transfire at gmail.com
Fri Jun 2 11:30:51 EDT 2006
Found a little problem with inheritor:
module X
inheritor :x, {}, :merge
end
class Module
include X
end
But it works if you do:
class Module
inheritor :x, {}, :merge
end
The reason is b/c of this code in inheritor.rb which decides how to
load the inheritor code (store in the Proc deflambda) into the
container.
if self == Class or self == Module
class_eval &deflambda
elsif is_a?(Class)
(class << self; self; end).class_eval &deflambda
elsif is_a?(Module)
class_inherit &deflambda
else # other Object
(class << self; self; end).class_eval &deflambda
end
The is_a?(Module) part is the most important is actaully the reason
inheritor exists at all --i.e. modules aren't class-level inheirtable
(which sucks to no end).
T.
More information about the Nitro-general
mailing list