Class: Chieftain::Command::Result
- Inherits:
-
Object
- Object
- Chieftain::Command::Result
- Defined in:
- lib/chieftain/command.rb
Overview
The type returned by a Command class when it is executed.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #error_codes ⇒ Object
- #error_messages ⇒ Object
- #failed? ⇒ Boolean (also: #error?)
-
#initialize(value, errors = []) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(value, errors = []) ⇒ Result
Returns a new instance of Result.
22 23 24 25 |
# File 'lib/chieftain/command.rb', line 22 def initialize(value, errors=[]) @errors = errors @value = value end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
26 27 28 |
# File 'lib/chieftain/command.rb', line 26 def errors @errors end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
26 27 28 |
# File 'lib/chieftain/command.rb', line 26 def value @value end |
Instance Method Details
#error_codes ⇒ Object
28 29 30 |
# File 'lib/chieftain/command.rb', line 28 def error_codes errors.map(&:code) end |
#error_messages ⇒ Object
32 33 34 |
# File 'lib/chieftain/command.rb', line 32 def errors.map(&:message) end |
#failed? ⇒ Boolean Also known as: error?
36 37 38 |
# File 'lib/chieftain/command.rb', line 36 def failed? !success? end |
#success? ⇒ Boolean
41 42 43 |
# File 'lib/chieftain/command.rb', line 41 def success? errors.empty? end |