1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/usr/bin/env ruby
require "rubygems"
require "camping"
Camping.goes :Sessions
require 'camping/session'
module Sessions
include Camping::Session
module Controllers
class One < R('/')
def get
@state = C::H['one',rand(100)]
puts "1:" + @state.inspect
redirect R(Two)
end
end
class Two < R('/steptwo')
def get
@state['two'] = "This is in two"
puts "2:" + @state.inspect
redirect R(Three)
end
end
class Three < R('/stepthree')
def get
@state['three'] = "This is in three"
puts "3:" + @state.inspect
return "Accumulated state across redirects: #{@state.inspect}"
redirect R(Three)
end
end
end
end
|