From: Gary Wright [mailto:gwtmp01 / mac.com] Sent: Monday, February 12, 2007 2:33 AM >On Feb 11, 2007, at 7:02 PM, Victor Zverok Shepelev wrote: > >> module Constants >> TEST = 5 >> end >> >> class A >> end >> >> a = A.new >> >> a.instance_eval{ >> extend Constants >> p TEST #<== here >> } > [...] > >It does seem a bit strange to be adding constants to the singleton >class. >Why not add them to A itself? That way you don't need to extend the >singleton class with the Constants module. > >class A > include Constants >end > >A.new.instance_eval { > p self.class::TEST # still a bit ugly... >} > Just due to this ugliness, and, additionally, I can't (or don't want) modify entire "A" class. More specifically, I have something like "scripts" - files, which are loaded and evaluated inside some objects. For example (it's about new GUI library, BTW): File tabs.rs ("rs" for "Ruby Script" :) ------ extend Win32::Keys on(TAB) do ...blah end on(SHIFT, TAB) do ... blah, blah end ----- This "script" is represents "tabs" behavior and it is evaluated in context of UI element, which I want this behavior to be added. The more verbose version, which is enforced by ruby 1.8.5, I don't like at all: on(Win32::Keys::TAB) do #fuuuuuu! It's a problem, so :( V.