Trans wrote:
> Logan Capaldo wrote:
> > On Aug 17, 2006, at 9:20 AM, Trans wrote:
> >
> > > Why? Becuase the module uses #define_method, and #define_method isn't
> > > defined in main.
> > >
> > > Which brings me to two questions:
> > >
> > > 1. How do I get around this problem? Please save me from having to
> > > delgate the whole module!
> > >
> > irb(main):006:0> case self
> > irb(main):007:1>   when Module, Class
> > irb(main):008:1>      define_method(:a) { 1 }
> > irb(main):009:1>   else
> > irb(main):010:1*      (class << self; self; end).class_eval
> > { define_method(:a) { 1 } }
> > irb(main):011:1>   end
>
> That's what I want to avoid -- "delegating the whole module" :-(

Craggy. It's even worse than that! If I delegate via the singelton of
main then:

  class << self
    def x; "x"; end
  end

  class C
    def q; x; end
  end

  C.new.q
  => NameError: undefined local variable or method `x' for
#<C:0xb7cfffc4>

(*frustrated*) It's not the same as defining at the top level.

T.