On Nov 15, 2005, at 8:36 PM, Nicholas Seckar wrote: > Hello all, > > I've run into an issue regarding the use of const_missing. This > issue revolves around the fact that these two cases are supposed to > behave differently from each other: > > irb(main):001:0> B = 10 > irb(main):002:0> module A; B; end > => 10 > irb(main):003:0> A::B > NameError: uninitialized constant A::B > from (irb):3 > > However it seems impossible to detect which case we are in within > the const_missing method. A more detailed explanation follows: > > Suppose we are lazy and avoid typing "require 'my_module.rb'" by > defining a const_missing that performs that require when MyModule > is first referenced. Now, suppose we are writing my_class, and wish > to include MyModule. So, we put this code in my_class.rb: I have found this type of laziness often leads to errors that are difficult to discover because somewhere else a MyModule was defined leaving the file I really want to use unrequired. require 'my_module' is really not that hard to type. -- Eric Hodel - drbrain / segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04