Module: Domainic::Command::InstanceMethods
- Defined in:
- lib/domainic/command/instance_methods.rb
Overview
Instance methods that are included in any class that includes Domainic::Command. These methods provide the core execution logic and error handling for commands.
Instance Method Summary collapse
-
#call(**context) ⇒ Result
Executes the command with the given context, handling any errors.
-
#call!(**input) ⇒ Result
Executes the command with the given context, raising any errors.
-
#execute ⇒ void
abstract
Executes the command's business logic.
Instance Method Details
#call(**context) ⇒ Result
Executes the command with the given context, handling any errors
20 21 22 23 24 |
# File 'lib/domainic/command/instance_methods.rb', line 20 def call(**context) call!(**context) rescue ExecutionError => e e.result end |
#call!(**input) ⇒ Result
Executes the command with the given context, raising any errors
33 34 35 36 37 38 39 |
# File 'lib/domainic/command/instance_methods.rb', line 33 def call!(**input) __execute_command!(input) rescue StandardError => e raise e if e.is_a?(ExecutionError) raise ExecutionError.new("#{self.class} failed", Result.failure(e, context.to_h)) end |
#execute ⇒ void
This method is abstract.
Subclass and override #execute to implement command behavior
This method returns an undefined value.
Executes the command's business logic
48 49 50 |
# File 'lib/domainic/command/instance_methods.rb', line 48 def execute raise NotImplementedError, "#{self.class} does not implement #execute" end |