On Mon, Sep 29, 2008 at 10:23 PM, Seth Thomas Rasmussen <[EMAIL PROTECTED]> wrote: > On Mon, Sep 29, 2008 at 9:48 PM, Jeff Hodges <[EMAIL PROTECTED]> wrote: >> Seth Thomas Rasmussen wrote: >>> >>> On Mon, Sep 29, 2008 at 9:23 PM, Hugh Sasse <[EMAIL PROTECTED]> wrote: >>>> >>>> On Mon, 29 Sep 2008, Jeff Hodges wrote: >>>> >>>>> Hey, >>>>> What's the right way to include widgets defined in files other than the >>>>> one >>>>> the shoes app is defined? >>> >>> Wouldn't you just define the widget class and then require the file >>> from your main app file? >>> >> >> That's what I did and what I described. > > Right. Sorry. > > So, the "unitialized constant Widget" error that I assume is the same > you found got me to remembering that the main Shoes app file lives in > a strange invisible namespace. In that file when you say Widget you > are really saying Shoes::Widget. I think. > > This simple example worked for me: > > http://gist.github.com/13728 > > I figured it out after remember that oddity of Shoes' Ruby > environment, so in a sense.. yay.. but really, sort of disturbingly > unintuitive for one coming to Shoes and thinking, "hai, ima do sum > roobie." > > Mr. _why, will namespacing in Shoes become more plain in the future, > or does this trickery facilitate something integral to Shoes' > character?
Perhaps a way to deal with this might be to enter the dark territory of things like ActiveSupport's dependencies.rb, which allows Rails apps to totally disown things like require() and setting up namespaces ahead of time. Module#const_missing could catch top level Widget references and turn them into Shoes::Widget references or something similar. The bit of code defining the widget creation methods could take into account top level subclasses. Etc. This is all starting to feel kinda hacky, though. And like I say, sometimes I feel that ActiveSupport's dependencies.rb may actually be sent to destroy us all. -- Seth Thomas Rasmussen http://greatseth.com
