Ask a Question related to Ruby, Design and Development.
-
Hal E. Fulton #1
const_missing
I just tried to use const_missing (which I think is a
neat idea).
Shouldn't it work at the top level? Am I doing something
wrong?
def const_missing
"not found"
end
p FOO
The above gives an error.
Hal
--
Hal Fulton
[email]hal9000@hypermetrics.com[/email]
Hal E. Fulton Guest
-
Using Module#const_missing for resolving "external" classes
Would it be possible to use const_missing to resolve external classes? Ie, I imagine doing something like this class Module def... -
Christoph R. #2
Re: const_missing
Hal E. Fulton wrote:
This should be> I just tried to use const_missing (which I think is a
> neat idea).
>
> Shouldn't it work at the top level? Am I doing something
> wrong?
>
> def const_missing
> "not found"
> end
---
def Object.const_missing(sym)
p sym
end
Foo
---
/Christoph
Christoph R. Guest
-
Christoph R. #3
Re: const_missing
Hal E. Fulton wrote:
....> The above gives an error.
On second thought your implementation could
have worked - the following may sheet more light
(confusion in my case;-) on it ...
--
def const_missing(sym)
p sym
end
def const_missingx(sym)
p sym
end
public :const_missing,:const_missingx
Object.const_missingx(:K) # :K
Object.const_missing(:K) # throws a NameError ???
---
/Christoph
Christoph R. Guest
-
Roger Deloy Pack #4
Re: const_missing
here's an example, for followers, since google brought me quickly here:
class Object
def self.const_missing c
p 'const is', c
end
end
Junior Member
- Join Date
- Sep 2010
- Posts
- 1



Reply With Quote

