Class: Errant::Success
Constant Summary
Constants inherited
from Result
Result::DEFAULT_EXCEPTIONS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Result
#flatten
Constructor Details
#initialize(*exceptions) ⇒ Success
Returns a new instance of Success.
5
6
7
|
# File 'lib/errant/success.rb', line 5
def initialize(*exceptions)
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
30
31
32
33
34
|
# File 'lib/errant/success.rb', line 30
def method_missing(name, *args, &block)
__copy[@value.send(name, *args, &block)]
rescue *exceptions => e
Failure[e]
end
|
Instance Attribute Details
#exceptions ⇒ Object
Returns the value of attribute exceptions.
3
4
5
|
# File 'lib/errant/success.rb', line 3
def exceptions
@exceptions
end
|
#value ⇒ Object
Returns the value of attribute value.
3
4
5
|
# File 'lib/errant/success.rb', line 3
def value
@value
end
|
Class Method Details
.[](value) ⇒ Object
54
55
56
|
# File 'lib/errant/success.rb', line 54
def self.[](value)
new(*Result::DEFAULT_EXCEPTIONS)[value]
end
|
Instance Method Details
#[](value) ⇒ Object
49
50
51
52
|
# File 'lib/errant/success.rb', line 49
def [](value)
@value = value
self
end
|
#each_error(&blk) ⇒ Object
22
23
24
|
# File 'lib/errant/success.rb', line 22
def each_error(&blk)
self
end
|
#map_error(&blk) ⇒ Object
26
27
28
|
# File 'lib/errant/success.rb', line 26
def map_error(&blk)
self
end
|
#or_else(&blk) ⇒ Object
36
37
38
|
# File 'lib/errant/success.rb', line 36
def or_else(&blk)
value
end
|
#successful? ⇒ Boolean
40
41
42
|
# File 'lib/errant/success.rb', line 40
def successful?
true
end
|
#to_a ⇒ Object
Also known as:
to_ary
44
45
46
|
# File 'lib/errant/success.rb', line 44
def to_a
__enumerable_value
end
|