OK, so fooling around further it looks like all instance variables get wiped at the beginning of every method within a Shoes subclass. That's OK I guess. So what's the preferred way to have some data that's shared from one Shoes URL to another? Passing it from one page to the next in the URL itself works -- if it's a string. If it's not a string, what should you use -- @@class_variables?

On Mar 11, 2009, at 11:37 PM, Edward Heil wrote:

this seems weird to me. Am I wrong to be able to expect to use a method inside a shoes-derived class to assign a value to an instance variable?

Check this out:

======

class BugTest < Shoes

 url '/', :main

 def assign_variable
   info "assigning variable."
   @foo = "bar"
   info "self is #{self}. @foo is #...@foo}"
 end

 def main
   title "main"
   info "in main.  self is #{self}. @foo is #...@foo}"
   button "assign variable" do
     assign_variable
     visit '/'
   end
 end
end

Shoes.app

=====


You run this, click the button, and get the following on the console:

in main. self is (#<Class:0x12493b0>::BugTest). @foo is

assigning variable.

self is (#<Class:0x12493b0>::BugTest @foo="bar"). @foo is bar

in main. self is (#<Class:0x12493b0>::BugTest). @foo is


====

Where'd the value 'bar' in @foo go after the assign_variable method returned?




Reply via email to