Class: Pathway::Result
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/pathway/result.rb
Defined Under Namespace
Modules: Mixin
Classes: Failure, Success
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
6
7
8
|
# File 'lib/pathway/result.rb', line 6
def error
@error
end
|
#value ⇒ Object
Returns the value of attribute value.
6
7
8
|
# File 'lib/pathway/result.rb', line 6
def value
@value
end
|
Class Method Details
.failure(error) ⇒ Object
43
|
# File 'lib/pathway/result.rb', line 43
def self.failure(error) = Failure.new(error)
|
.result(object) ⇒ Object
45
46
47
|
# File 'lib/pathway/result.rb', line 45
def self.result(object)
object.is_a?(Result) ? object : success(object)
end
|
.success(value) ⇒ Object
42
|
# File 'lib/pathway/result.rb', line 42
def self.success(value) = Success.new(value)
|
Instance Method Details
#deconstruct ⇒ Object
50
|
# File 'lib/pathway/result.rb', line 50
def deconstruct = [value_for_deconstruct]
|
#deconstruct_keys(keys) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/pathway/result.rb', line 52
def deconstruct_keys(keys)
if value_for_deconstruct.respond_to?(:deconstruct_keys)
value_for_deconstruct.deconstruct_keys(keys)
else
{}
end
end
|
#failure? ⇒ Boolean
49
|
# File 'lib/pathway/result.rb', line 49
def failure? = !success?
|