From: Tom Cloyd Date: 2009-04-17T23:39:33+09:00 Subject: Re: simple module method call question Ben Lovell wrote: > On Fri, Apr 17, 2009 at 1:00 PM, Tom Cloyd wrote: > > >> 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? Because the name of one of my two modules isn't known until class 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: > > eval("include Utils; Utils.orph_chk") > Hmm. I tried that, and got some kind of method error on the "include". I 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@tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~