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(first, second) ⇒ Global
Returns a new instance of Global.
25
26
27
|
# File 'lib/bbmb/html/state/global.rb', line 25
def initialize(first, second)
super(first, second)
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
40
41
|
# File 'lib/bbmb/html/state/global.rb', line 40
def direct_argument_keys
end
|
#direct_arguments ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/bbmb/html/state/global.rb', line 32
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
42
43
44
|
# File 'lib/bbmb/html/state/global.rb', line 42
def direct_request?(event)
requested_event(event) == direct_event
end
|
#logout ⇒ Object
28
29
30
31
|
# File 'lib/bbmb/html/state/global.rb', line 28
def logout
@session.logout
State::Login.new(@session, nil)
end
|
#requested_event(event) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/bbmb/html/state/global.rb', line 45
def requested_event(event)
if(args = direct_arguments)
[ event, args ]
else
event
end
end
|
#trigger(event) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/bbmb/html/state/global.rb', line 52
def trigger(event)
if(direct_request?(event))
self
else
super
end
end
|
59
60
61
62
63
64
65
66
67
|
# File 'lib/bbmb/html/state/global.rb', line 59
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
|