Class: Chieftain::Command::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/chieftain/command.rb

Overview

The type returned by a Command class when it is executed.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorsObject (readonly)

Returns the value of attribute errors.



26
27
28
# File 'lib/chieftain/command.rb', line 26

def errors
  @errors
end

#valueObject (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_codesObject



28
29
30
# File 'lib/chieftain/command.rb', line 28

def error_codes
  errors.map(&:code)
end

#error_messagesObject



32
33
34
# File 'lib/chieftain/command.rb', line 32

def error_messages
  errors.map(&:message)
end

#failed?Boolean Also known as: error?

Returns:

  • (Boolean)


36
37
38
# File 'lib/chieftain/command.rb', line 36

def failed?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/chieftain/command.rb', line 41

def success?
  errors.empty?
end