Thanks - actually it does answer the question, but it also answers that
I have to wait until Ruby 1.9 for the "fix"
that is unless there is a workaround way (until 1.9) to
doInConstanScopeOf [Module] do
# so instead of 'Module::CONST' one can do 'CONST'
end
so one could do
def doIt(&block)
doInConstanScopeOf AModule &block
end
and explicitly define the constant scope to be the scope of "self.class"
so when will the fabled 1.9 be available :)
Florian Gilcher wrote:
> This is a bit of a strange problem. Ruby 1.8 resolves constants
> lexically.
>
> So you are actually referring to ::CONST there.
>
> In Ruby 1.9, this is different. In Ruby 1.9, Constants are resolved by
> self.
> So, in short:
>
> class A
> module B
> end
> end
>
> A.new.instance_eval do
> B
> end
>
> crashes in 1.8, but resolves B as A::B in 1.9. Some people hate that
> change
> in behaviour, I like it.
>
> It doesn't directly answer your question, but I hope it gives you
> enough insight to find a way to do what you want.
>
> Regards,
> Florian
>
> On Oct 10, 2009, at 12:14 AM, Peter Pk wrote:
>
>> <br>
>> instance of a class that defines the constant or subclass of it or
>> "const_missing"
>>
>> This so it can be like Java to get "this.CONST"
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>
> --
> Florian Gilcher
>
> smtp: flo / andersground.net
> jabber: Skade / jabber.ccc.de
> gpg: 533148E2
--
Posted via http://www.ruby-forum.com/.