Class: LaunchDarkly::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/util.rb

Overview

A Result is used to reflect the outcome of any operation.

Results can either be considered a success or a failure.

In the event of success, the Result will contain an option, nullable value to hold any success value back to the calling function.

If the operation fails, the Result will contain an error describing the value.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorString? (readonly)



54
55
56
# File 'lib/ldclient-rb/util.rb', line 54

def error
  @error
end

#exceptionException? (readonly)



59
60
61
# File 'lib/ldclient-rb/util.rb', line 59

def exception
  @exception
end

#valueObject? (readonly)



49
50
51
# File 'lib/ldclient-rb/util.rb', line 49

def value
  @value
end

Class Method Details

.fail(error, exception = nil) ⇒ Result

Create a failed result with the provided error description.



33
34
35
# File 'lib/ldclient-rb/util.rb', line 33

def self.fail(error, exception = nil)
  Result.new(nil, error, exception)
end

.success(value) ⇒ Result

Create a successful result with the provided value.



22
23
24
# File 'lib/ldclient-rb/util.rb', line 22

def self.success(value)
  Result.new(value)
end

Instance Method Details

#success?Boolean

Was this result successful or did it encounter an error?



42
43
44
# File 'lib/ldclient-rb/util.rb', line 42

def success?
  @error.nil?
end