Class: NotMonads::Result::Failure
Instance Method Summary
collapse
#initialize
Instance Method Details
#==(other) ⇒ Object
70
71
72
|
# File 'lib/not_monads/result.rb', line 70
def ==(other)
other.is_a?(self.class) && failure == other.failure
end
|
#===(other) ⇒ Object
74
75
76
|
# File 'lib/not_monads/result.rb', line 74
def ===(other)
other.instance_of?(self.class) && failure === other.failure
end
|
#failure ⇒ Object
66
67
68
|
# File 'lib/not_monads/result.rb', line 66
def failure
@value
end
|
#failure? ⇒ Boolean
41
42
43
|
# File 'lib/not_monads/result.rb', line 41
def failure?
true
end
|
#success? ⇒ Boolean
45
46
47
|
# File 'lib/not_monads/result.rb', line 45
def success?
false
end
|
#to_s ⇒ Object
Also known as:
inspect
49
50
51
|
# File 'lib/not_monads/result.rb', line 49
def to_s
"Failure(#{failure.inspect})"
end
|
#value! ⇒ Object
54
55
56
|
# File 'lib/not_monads/result.rb', line 54
def value!
raise Error, "value! was called on #{self}"
end
|
#value_or(val = nil) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/not_monads/result.rb', line 58
def value_or(val = nil)
if block_given?
yield
else
val
end
end
|