Interesting. I didn't get the console error that you did, but that must be because I'm running r970 and I assume you're running r1009?
I can't get your re-formed example to work with r970 either. I guess it's time I do a git clone of the sources so I can keep on top of all the bug fixes and get the 'app' method. By the way, I didn't see the 'app' method either when I looked at stack's methods, but I though I was just missing something. Turns out I am - the latest version. Thanks guys ----- Original Message ---- From: Seth Thomas Rasmussen <[EMAIL PROTECTED]> To: [email protected] Sent: Wednesday, October 1, 2008 12:09:17 PM Subject: Re: Where did the app object go? On Mon, Sep 29, 2008 at 11:36 PM, recursor <[EMAIL PROTECTED]> wrote: > I want to do some things with a class outside my app block, but I cannot get > it to work. I even went so far as > to copy the example given in http://help.shoooes.net/Rules.html under the > 'Block Redirection' section and try > to use it: > > class Messenger > def initialize(stack) > @stack = stack > end > def add(msg) > @stack.app do > @stack.append do > para msg > end > end > end > end > > ---snip-- (below is code that I added) > > Shoes.app do > @msg = Messenger.new(stack) > button 'go' do > @msg.add "dy-no-mite" > end > end > > The 'add' method should retrieve the app object from the stack object, but > when I do an alert @stack.app.inspect, I get: > > (Shoes) > > and the @stack.append does not work. Any thoughts? Aha. So, after fully reading the Rules, I developed a theory that the example shown there is all wrong because inside the app() block, self is changed to your app, which has no @stack instance. Running your sample code, that seems confirmed with the error "undefined method 'append' for nil:NilClass" shown in the console. This works: class Messenger def initialize(stack) @stack = stack end def add(msg) @stack.app do @messages.append do para msg end end end end Shoes.app do @messages = stack @messenger = Messenger.new @messages button "go" do @messenger.add "dy-no-mite" end end -- Seth Thomas Rasmussen http://greatseth.com
