Module: App::Command::MaskingInstanceMethods
- Defined in:
- lib/has_helpers/app/command.rb
Instance Method Summary collapse
-
#fail(*args) ⇒ Object
Delegate fails to the result object.
- #fail!(*args) ⇒ Object
- #result ⇒ Object
-
#run ⇒ Object
Mask the user-defined (or stubbed) run method and wrap it with some functionality.
Instance Method Details
#fail(*args) ⇒ Object
Delegate fails to the result object.
92 93 94 |
# File 'lib/has_helpers/app/command.rb', line 92 def fail(*args) result.fail(*args) end |
#fail!(*args) ⇒ Object
96 97 98 |
# File 'lib/has_helpers/app/command.rb', line 96 def fail!(*args) result.fail!(*args) end |
#result ⇒ Object
87 88 89 |
# File 'lib/has_helpers/app/command.rb', line 87 def result @result ||= Result.new end |
#run ⇒ Object
Mask the user-defined (or stubbed) run method and wrap it with some functionality. This provides a Result object which is accessible within the user-defined run method. This method should never raise an exception, but rather it should always return a result.
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/has_helpers/app/command.rb', line 73 def run(...) # Execute the user-defined run method. begin run_return_value = super(...) result.value = run_return_value unless result.explicit_value_is_set rescue Exception => e # rubocop:disable Lint/RescueException result.error = e. result.exception = e end # Return the result. ResultProxy.new(result) end |