Class: FlowChat::BaseApp
- Inherits:
-
Object
show all
- Defined in:
- lib/flow_chat/base_app.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(context) ⇒ BaseApp
Returns a new instance of BaseApp.
5
6
7
8
9
10
|
# File 'lib/flow_chat/base_app.rb', line 5
def initialize(context)
@context = context
@session = context.session
@input = context.input
@navigation_stack = []
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
3
4
5
|
# File 'lib/flow_chat/base_app.rb', line 3
def context
@context
end
|
Returns the value of attribute input.
3
4
5
|
# File 'lib/flow_chat/base_app.rb', line 3
def input
@input
end
|
#navigation_stack ⇒ Object
Returns the value of attribute navigation_stack.
3
4
5
|
# File 'lib/flow_chat/base_app.rb', line 3
def navigation_stack
@navigation_stack
end
|
#session ⇒ Object
Returns the value of attribute session.
3
4
5
|
# File 'lib/flow_chat/base_app.rb', line 3
def session
@session
end
|
Instance Method Details
67
68
69
|
# File 'lib/flow_chat/base_app.rb', line 67
def contact_name
nil
end
|
#gateway ⇒ Object
47
48
49
|
# File 'lib/flow_chat/base_app.rb', line 47
def gateway
context["request.gateway"]
end
|
#go_back ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/flow_chat/base_app.rb', line 28
def go_back
return false if navigation_stack.empty?
@context.input = nil
current_screen = navigation_stack.last
session.delete(current_screen)
raise FlowChat::Interrupt::RestartFlow.new
end
|
#location ⇒ Object
71
72
73
|
# File 'lib/flow_chat/base_app.rb', line 71
def location
nil
end
|
75
76
77
|
# File 'lib/flow_chat/base_app.rb', line 75
def media
nil
end
|
#message_id ⇒ Object
59
60
61
|
# File 'lib/flow_chat/base_app.rb', line 59
def message_id
context["request.message_id"]
end
|
#msisdn ⇒ Object
55
56
57
|
# File 'lib/flow_chat/base_app.rb', line 55
def msisdn
context["request.msisdn"]
end
|
43
44
45
|
# File 'lib/flow_chat/base_app.rb', line 43
def platform
context["request.platform"]
end
|
#say(msg, media: nil) ⇒ Object
#screen(key) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/flow_chat/base_app.rb', line 12
def screen(key)
raise ArgumentError, "a block is expected" unless block_given?
raise ArgumentError, "screen has already been presented" if navigation_stack.include?(key)
navigation_stack << key
return session.get(key) if session.get(key).present?
user_input = prepare_user_input
prompt = FlowChat::Prompt.new user_input
@input = nil
value = yield prompt
session.set(key, value)
value
end
|
#timestamp ⇒ Object
63
64
65
|
# File 'lib/flow_chat/base_app.rb', line 63
def timestamp
context["request.timestamp"]
end
|
#user_id ⇒ Object
51
52
53
|
# File 'lib/flow_chat/base_app.rb', line 51
def user_id
context["request.user_id"]
end
|