From: Peter Pk Date: 2009-10-11T22:38:10+09:00 Subject: Re: Scope of constants in instance_eval pharrington wrote: > On Oct 10, 8:48�am, Peter Pk wrote: > > And what do you mean by "waiting" until Ruby 1.9? 1.9.1's been > released and stable for the better part of this year now. That there are convenient installers/packages/etc available and documented for the OS' and distros that our admin sets up our development machines for :) It looks like one still has to compile from source in many cases (such as Fedora). Windows was easy as someone made an NSIS installer :) BTW 1.9 does exactly what I want and that is to overide const_missing on a specific class. The old behavior also still works if not overidden (as the static method on Object, but the "self" will be the self of the object that was missing the constant. IMHO way better behavior to allow object oriented overides. One can also on a specific class do: alias :const_missing :__send__ which will (efficiently) if a const is missing direct it to an attribute of the same name so you don't have to do thing = XXX() and can access it by thing = XXX >> >> >> >> > change >> >>
>> > smtp: � f...@andersground.net >> > jabber: Sk...@jabber.ccc.de >> > gpg: � �533148E2 >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > well in Ruby 1.8 something like this works (obviously not it all > cases, but you get the gist and can fix it as needed): > > Obj.new { puts "CONST = #{self.class.const_get("CONST")}" } -- Posted via http://www.ruby-forum.com/.