Class: FlowChat::Context
Instance Method Summary
collapse
#instrument, instrument, report_api_error
Constructor Details
Returns a new instance of Context.
5
6
7
8
9
10
11
12
|
# File 'lib/flow_chat/context.rb', line 5
def initialize
@data = {}.with_indifferent_access
self.class.instrument(Events::CONTEXT_CREATED, {
gateway: @data["request.gateway"]
})
end
|
Instance Method Details
#[](key) ⇒ Object
14
15
16
17
18
|
# File 'lib/flow_chat/context.rb', line 14
def [](key)
value = @data[key]
FlowChat.logger.debug { "Context: Getting '#{key}' = #{value.inspect}" } if key != "session.store" value
end
|
#[]=(key, value) ⇒ Object
20
21
22
23
|
# File 'lib/flow_chat/context.rb', line 20
def []=(key, value)
FlowChat.logger.debug { "Context: Setting '#{key}' = #{value.inspect}" } if key != "session.store" && key != "controller" @data[key] = value
end
|
#controller ⇒ Object
39
|
# File 'lib/flow_chat/context.rb', line 39
def controller = @data["controller"]
|
#flow ⇒ Object
def request = controller.request
43
|
# File 'lib/flow_chat/context.rb', line 43
def flow = @data["flow.class"]
|
25
|
# File 'lib/flow_chat/context.rb', line 25
def input = @data["request.input"]
|
27
28
29
30
|
# File 'lib/flow_chat/context.rb', line 27
def input=(value)
FlowChat.logger.debug { "Context: Setting input = '#{value}'" }
@data["request.input"] = value
end
|
#session ⇒ Object
32
|
# File 'lib/flow_chat/context.rb', line 32
def session = @data["session"]
|
#session=(value) ⇒ Object
34
35
36
37
|
# File 'lib/flow_chat/context.rb', line 34
def session=(value)
FlowChat.logger.debug { "Context: Setting session = #{value.class.name}" }
@data["session"] = value
end
|