B
Brian Mitchell
I was wondering why Module.nesting is not consitent when called from
module_eval:
class Object
def Object.inherited(sub)
p sub.module_eval { Module.nesting } # [Object]
p sub.module_eval("Module.nesting") # [A::B, Object]
end
end
module A
class B
p Module.nesting # [A::B, A] OK
end
p Module.nesting # [A] OK
end
The evals inside of Object.inherited don't return the same thing. I
think I understand why, classes are objects that can be shared across
bindings but how would I go about fixing this without touching any of
"module A ... end"?
Thanks.
Brian.
module_eval:
class Object
def Object.inherited(sub)
p sub.module_eval { Module.nesting } # [Object]
p sub.module_eval("Module.nesting") # [A::B, Object]
end
end
module A
class B
p Module.nesting # [A::B, A] OK
end
p Module.nesting # [A] OK
end
The evals inside of Object.inherited don't return the same thing. I
think I understand why, classes are objects that can be shared across
bindings but how would I go about fixing this without touching any of
"module A ... end"?
Thanks.
Brian.