Class: Cuprum::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/cuprum/result.rb

Overview

Data object that encapsulates the result of calling a Cuprum function or operation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsArray

Returns the errors (if any) generated when the function was called.

Returns:

  • (Array)

    the errors (if any) generated when the function was called.



14
15
16
# File 'lib/cuprum/result.rb', line 14

def errors
  @errors ||= []
end

#valueObject

Returns the value returned by calling the function.

Returns:

  • (Object)

    the value returned by calling the function.



8
9
10
# File 'lib/cuprum/result.rb', line 8

def value
  @value
end

Instance Method Details

#failure?Boolean

Returns false if the function did not generate any errors, otherwise true.

Returns:

  • (Boolean)

    false if the function did not generate any errors, otherwise true.



20
21
22
# File 'lib/cuprum/result.rb', line 20

def failure?
  !errors.empty?
end

#success?Boolean

Returns true if the function did not generate any errors, otherwise false.

Returns:

  • (Boolean)

    true if the function did not generate any errors, otherwise false.



26
27
28
# File 'lib/cuprum/result.rb', line 26

def success?
  errors.empty?
end