Class: FlowChat::Context
- Inherits:
-
Object
- Object
- FlowChat::Context
- Includes:
- Instrumentation
- Defined in:
- lib/flow_chat/context.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #controller ⇒ Object
-
#flow ⇒ Object
def request = controller.request.
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #input ⇒ Object
- #input=(value) ⇒ Object
- #session ⇒ Object
- #session=(value) ⇒ Object
Methods included from Instrumentation
Constructor Details
#initialize ⇒ Context
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 # Use instrumentation for context creation 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" # Avoid logging session store object 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" # Avoid logging large objects @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"] |
#input ⇒ Object
25 |
# File 'lib/flow_chat/context.rb', line 25 def input = @data["request.input"] |
#input=(value) ⇒ Object
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"] |