Class: Cliqr::Executor::Router Private
- Inherits:
-
Object
- Object
- Cliqr::Executor::Router
- Defined in:
- lib/cliqr/executor/router.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Used for routing the command to the appropriate command handler based on the interface config
Instance Method Summary collapse
-
#handle(context, **options) ⇒ Integer
private
Handle a command invocation by routing to appropriate command handler.
-
#initialize(config) ⇒ Cliqr::Interface::Router
constructor
private
Create a new Router instance.
Constructor Details
#initialize(config) ⇒ Cliqr::Interface::Router
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new Router instance
16 17 18 |
# File 'lib/cliqr/executor/router.rb', line 16 def initialize(config) @config = config end |
Instance Method Details
#handle(context, **options) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Handle a command invocation by routing to appropriate command handler
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cliqr/executor/router.rb', line 26 def handle(context, **) handler = @config.handler runner = CommandRunnerFactory.get() runner.run do if handler.is_a?(Proc) context.instance_eval(&handler) else handler.execute(context) end end end |