Class: Kommando::CommandResult::Failure
- Inherits:
-
Object
- Object
- Kommando::CommandResult::Failure
- Defined in:
- lib/kommando/command_result.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #deconstruct_keys(_) ⇒ Object
- #error? ⇒ Boolean
-
#initialize(error) ⇒ Failure
constructor
A new instance of Failure.
- #success? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(error) ⇒ Failure
Returns a new instance of Failure.
44 45 46 47 48 49 |
# File 'lib/kommando/command_result.rb', line 44 def initialize(error) raise ArgumentError, 'missing `:error` key' unless error.key?(:error) raise ArgumentError, 'missing `:command` key' unless error.key?(:command) raise ArgumentError, 'missing `:parameters` key' unless error.key?(:parameters) @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
42 43 44 |
# File 'lib/kommando/command_result.rb', line 42 def error @error end |
Instance Method Details
#deconstruct_keys(_) ⇒ Object
63 64 65 |
# File 'lib/kommando/command_result.rb', line 63 def deconstruct_keys(_) { error: error }.merge(@error) end |
#error? ⇒ Boolean
59 60 61 |
# File 'lib/kommando/command_result.rb', line 59 def error? true end |
#success? ⇒ Boolean
55 56 57 |
# File 'lib/kommando/command_result.rb', line 55 def success? false end |
#value ⇒ Object
51 52 53 |
# File 'lib/kommando/command_result.rb', line 51 def value raise NonExistentValue, 'Failure results do not have values' end |