File: sessions.rb

package info (click to toggle)
camping 3.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,312 kB
  • sloc: ruby: 5,032; javascript: 2,362; makefile: 29
file content (38 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (7)
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