Class: Dry::Monads::Validated::Invalid Private
- Inherits:
-
Dry::Monads::Validated
- Object
- Dry::Monads::Validated
- Dry::Monads::Validated::Invalid
- Defined in:
- lib/dry/monads/validated.rb,
lib/dry/monads/maybe.rb,
lib/dry/monads/result.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Invalid result
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
private
The value stored inside.
-
#trace ⇒ String
readonly
Line where the value was constructed.
Instance Method Summary collapse
- #===(other) ⇒ Boolean private
-
#alt_map(proc = Undefined, &block) ⇒ Object
private
Lifts a block/proc over Invalid.
-
#apply(val = Undefined, &block) ⇒ Object
private
Collects errors (ignores valid results).
-
#fmap(_ = nil) ⇒ Validated::Invalid
private
Ignores the passed argument and returns self.
-
#initialize(error, trace = RightBiased::Left.trace_caller) ⇒ Invalid
constructor
private
A new instance of Invalid.
- #inspect ⇒ String (also: #to_s) private
-
#or(proc = Undefined, &block) ⇒ Object
private
Yields the given callable and returns the result.
-
#to_maybe ⇒ Maybe::None
Converts to Maybe::None.
-
#to_result ⇒ Result::Failure
Converts to Result::Failure.
Methods inherited from Dry::Monads::Validated
Constructor Details
#initialize(error, trace = RightBiased::Left.trace_caller) ⇒ Invalid
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Invalid.
154 155 156 157 158 159 |
# File 'lib/dry/monads/validated.rb', line 154 def initialize(error, trace = RightBiased::Left.trace_caller) super() @error = error @trace = trace end |
Instance Attribute Details
#error ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The value stored inside
144 145 146 |
# File 'lib/dry/monads/validated.rb', line 144 def error @error end |
#trace ⇒ String (readonly)
Line where the value was constructed
150 151 152 |
# File 'lib/dry/monads/validated.rb', line 150 def trace @trace end |
Instance Method Details
#===(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
222 223 224 |
# File 'lib/dry/monads/validated.rb', line 222 def ===(other) other.instance_of?(self.class) && error === other.error end |
#alt_map(proc) ⇒ Validated::Invalid #alt_map ⇒ Validated::Invalid
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lifts a block/proc over Invalid
188 189 190 191 |
# File 'lib/dry/monads/validated.rb', line 188 def alt_map(proc = Undefined, &block) f = Undefined.default(proc, block) self.class.new(f.(error), RightBiased::Left.trace_caller) end |
#apply(val) ⇒ Validated::Invalid #apply ⇒ Validated::Invalid
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Collects errors (ignores valid results)
171 172 173 174 175 176 |
# File 'lib/dry/monads/validated.rb', line 171 def apply(val = Undefined, &block) Undefined .default(val, &block) .alt_map { @error + _1 } .fmap { return self } end |
#fmap(_ = nil) ⇒ Validated::Invalid
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Ignores the passed argument and returns self
196 197 198 |
# File 'lib/dry/monads/validated.rb', line 196 def fmap(_ = nil) self end |
#inspect ⇒ String Also known as: to_s
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
215 216 217 |
# File 'lib/dry/monads/validated.rb', line 215 def inspect "Invalid(#{@error.inspect})" end |
#or(proc) ⇒ Object #or ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Yields the given callable and returns the result
210 211 212 |
# File 'lib/dry/monads/validated.rb', line 210 def or(proc = Undefined, &block) Undefined.default(proc, block).call end |
#to_maybe ⇒ Maybe::None
Converts to Maybe::None
445 446 447 |
# File 'lib/dry/monads/maybe.rb', line 445 def to_maybe Maybe::None.new(RightBiased::Left.trace_caller) end |
#to_result ⇒ Result::Failure
Converts to Result::Failure
472 473 474 |
# File 'lib/dry/monads/result.rb', line 472 def to_result Result::Failure.new(error, RightBiased::Left.trace_caller) end |