P
Peter Pk
so If I do<br>
class MyObj < Module<br>
CONST = 'xxx'<br>
def initalialize(&block)<br>
super(&block)<br>
end<br>
end<br>
<br>
MyObj.new do<br>
puts("CONST = #{CONST}")<br>
end<br>
<br>
<br>
# this will print<br>
unitialized constant CONST<br>
<br>
So how do I create a "constant" ie: attribute with leading upper case
char that is resolvable within "instance_eval()" for a particular
instance of a class that defines the constant or subclass of it or class
that includes a module that defines the constant?
I tried overriding "const_missing" but as a static method on class
Object I see no way to determine the "self" that was active when the
constant was not resolved, If so I could then make it happen, by
examinig the "self" for it's class etc and look for the constants in
them
Kind of like i'd like to be able to get caller[0].binding.self inside
"const_missing"
This so it can be like Java to get "this.CONST"
class MyObj < Module<br>
CONST = 'xxx'<br>
def initalialize(&block)<br>
super(&block)<br>
end<br>
end<br>
<br>
MyObj.new do<br>
puts("CONST = #{CONST}")<br>
end<br>
<br>
<br>
# this will print<br>
unitialized constant CONST<br>
<br>
So how do I create a "constant" ie: attribute with leading upper case
char that is resolvable within "instance_eval()" for a particular
instance of a class that defines the constant or subclass of it or class
that includes a module that defines the constant?
I tried overriding "const_missing" but as a static method on class
Object I see no way to determine the "self" that was active when the
constant was not resolved, If so I could then make it happen, by
examinig the "self" for it's class etc and look for the constants in
them
Kind of like i'd like to be able to get caller[0].binding.self inside
"const_missing"
This so it can be like Java to get "this.CONST"