Class: BBMB::Html::State::Global
- Inherits:
-
SBSM::State
- Object
- SBSM::State
- BBMB::Html::State::Global
show all
- Defined in:
- lib/bbmb/html/state/global.rb,
lib/bbmb/html/state/global_predefine.rb
Direct Known Subclasses
ChangePassword, CurrentOrder, Customer, Customers, Favorites, History, Info, Order, Orders, Result, ShowPass
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(session, model) ⇒ Global
Returns a new instance of Global.
25
26
27
28
|
# File 'lib/bbmb/html/state/global.rb', line 25
def initialize(session, model)
SBSM.info "BBMB::Html::State Global session #{session.class} model #{model.class}"
super(session, model)
end
|
Class Method Details
.mandatory(*keys) ⇒ Object
11
12
13
14
15
|
# File 'lib/bbmb/html/state/global_predefine.rb', line 11
def mandatory(*keys)
define_method(:_mandatory) { keys }
define_method(:mandatory) { _mandatory }
define_method(:mandatory?) { |key| mandatory.include?(key) }
end
|
Instance Method Details
#direct_argument_keys ⇒ Object
42
43
|
# File 'lib/bbmb/html/state/global.rb', line 42
def direct_argument_keys
end
|
#direct_arguments ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/bbmb/html/state/global.rb', line 34
def direct_arguments
if(keys = direct_argument_keys)
keys.inject({}) { |memo, key|
memo.store(key, @session.user_input(key))
memo
}
end
end
|
#direct_request?(event) ⇒ Boolean
44
45
46
|
# File 'lib/bbmb/html/state/global.rb', line 44
def direct_request?(event)
requested_event(event) == direct_event
end
|
#logout ⇒ Object
29
30
31
32
33
|
# File 'lib/bbmb/html/state/global.rb', line 29
def logout
SBSM.info "BBMB::Html::State Global logout"
@session.logout
State::Login.new(@session, nil)
end
|
#requested_event(event) ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/bbmb/html/state/global.rb', line 47
def requested_event(event)
if(args = direct_arguments)
[ event, args ]
else
event
end
end
|
#trigger(event) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/bbmb/html/state/global.rb', line 54
def trigger(event)
if(direct_request?(event))
self
else
super
end
end
|
61
62
63
64
65
66
67
68
69
|
# File 'lib/bbmb/html/state/global.rb', line 61
def user_input(*args)
data = super
data.each { |key, val|
if(val.is_a?(String))
data.store(key, val.empty? ? nil : u(val))
end
}
data
end
|