Class: Stealth::Dispatcher
- Inherits:
-
Object
- Object
- Stealth::Dispatcher
- Defined in:
- lib/stealth/dispatcher.rb
Overview
Responsible for coordinating incoming messages
1. Receives incoming request params
2. Initializes respective service request handler
3. Processes params through service request handler (might be async)
4. Inits base StealthController with state params returned from the service
request handler
5. Returns an HTTP response to be returned to the requestor
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#message_handler ⇒ Object
readonly
Returns the value of attribute message_handler.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #coordinate ⇒ Object
-
#initialize(service:, params:, headers:) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #process ⇒ Object
Constructor Details
#initialize(service:, params:, headers:) ⇒ Dispatcher
Returns a new instance of Dispatcher.
17 18 19 20 21 22 23 24 25 |
# File 'lib/stealth/dispatcher.rb', line 17 def initialize(service:, params:, headers:) @service = service @params = params @headers = headers @message_handler = .new( params: params, headers: headers ) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
15 16 17 |
# File 'lib/stealth/dispatcher.rb', line 15 def headers @headers end |
#message_handler ⇒ Object (readonly)
Returns the value of attribute message_handler.
15 16 17 |
# File 'lib/stealth/dispatcher.rb', line 15 def @message_handler end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
15 16 17 |
# File 'lib/stealth/dispatcher.rb', line 15 def params @params end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
15 16 17 |
# File 'lib/stealth/dispatcher.rb', line 15 def service @service end |
Instance Method Details
#coordinate ⇒ Object
27 28 29 |
# File 'lib/stealth/dispatcher.rb', line 27 def coordinate .coordinate end |
#process ⇒ Object
31 32 33 34 35 |
# File 'lib/stealth/dispatcher.rb', line 31 def process = .process bot_controller = BotController.new(service_message: ) bot_controller.route end |