File: controller.rb

package info (click to toggle)
tempura 0.1.2r3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 400 kB
  • ctags: 399
  • sloc: ruby: 1,826; makefile: 84; xml: 80
file content (36 lines) | stat: -rw-r--r-- 635 bytes parent folder | download
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
require 'tempura/div'

class Controller < Tempura::Div

  attr_reader :lang

  def self.set_model_factory( factory )
    @@model_factory = factory
  end

  def initialize(session)
    super(session)
    @model = @@model_factory.new
  end

  def do_lang(context, params)
    @lang = params['lang'].first
    select_template( @lang )
  end

  def do_add(context, params)
    name = params['name'].first
    price = params['price'].first.to_i
    @model.add_item(name, price)
  end

  def do_del(context, params)
    name = params['name'].first
    @model.del_item(name)
  end

  def do_reset(context, params)
    @model.reset
  end

end