Re: simple module method call question
- From: Tom Cloyd <tomcloyd@xxxxxxxxxxx>
- Date: Fri, 17 Apr 2009 09:39:33 -0500
Ben Lovell wrote:
On Fri, Apr 17, 2009 at 1:00 PM, Tom Cloyd <tomcloyd@xxxxxxxxxxx> wrote:Because the name of one of my two modules isn't known until class
eval("Utils.orph_chk") <= I will be replacing the string with a
construction using a variable, in the final version
This always fails. I've tried every trick I can think of, but always I get
this:
../lib/setnet/SN.rb:579:in `proc_command': undefined method `orph_chk' for
Utils:Module (NoMethodError)
from ../lib/setnet/SN.rb:229:in `eval'
from ../lib/setnet/SN.rb:579:in `proc_command'
from ../lib/setnet/SN.rb:229:in `user_interface'
from ../lib/setnet/SN.rb:146:in `manage'
from ../lib/setnet/SN.rb:68:in `startup'
from ./setnet:28
Can someone suggest why I'm not able to get to this method?
Any suggestions would be much appreciated. I cannot quite figure out what
to try next.
Thanks,
Tom
Hi,
Why are you eval'ing this?
instantiation time. It could literally be anything. That said, I'm not
at all sure my approach is the best. It's just the only one I could
think of. It's also my very first use of eval, and it well may be poorly
chosen.
This works:Hmm. I tried that, and got some kind of method error on the "include". I
eval("include Utils; Utils.orph_chk")
studied it for a good long while and simply couldn't see the problem.
I would think it has something to do with your binding when you eval.Yeah, me two. I've never even thought about binding issues before, but I
sure am now!
Thanks for your thoughts.
t.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@xxxxxxxxxxxx >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.
- References:
- simple module method call question
- From: Tom Cloyd
- Re: simple module method call question
- From: Ben Lovell
- simple module method call question
- Prev by Date: Re: simple module method call question
- Next by Date: Re: Python on LLVM
- Previous by thread: Re: simple module method call question
- Next by thread: Mocha: does_not_expect
- Index(es):
Relevant Pages
|