Class: Lyra::CommandHandler
- Inherits:
-
Object
- Object
- Lyra::CommandHandler
- Defined in:
- lib/lyra/command_handler.rb
Overview
Command handler for processing commands in hijack mode
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(command) ⇒ CommandHandler
constructor
A new instance of CommandHandler.
Constructor Details
#initialize(command) ⇒ CommandHandler
Returns a new instance of CommandHandler.
13 14 15 |
# File 'lib/lyra/command_handler.rb', line 13 def initialize(command) @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
11 12 13 |
# File 'lib/lyra/command_handler.rb', line 11 def command @command end |
Class Method Details
.handle(command) ⇒ Object
5 6 7 8 |
# File 'lib/lyra/command_handler.rb', line 5 def handle(command) handler = new(command) handler.call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lyra/command_handler.rb', line 17 def call case command when Commands::CreateCommand handle_create when Commands::UpdateCommand handle_update when Commands::DestroyCommand handle_destroy else CommandResult.failure(error: "Unknown command type") end rescue => e CommandResult.failure(error: e.) end |