Class: Dry::Monads::Validated::Valid Private
- Inherits:
-
Dry::Monads::Validated
- Object
- Dry::Monads::Validated
- Dry::Monads::Validated::Valid
- 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.
Valid result
Instance Method Summary collapse
- #===(other) ⇒ Boolean private
-
#alt_map(_ = nil) ⇒ Validated::Valid
private
Ignores values and returns self, see Invalid#alt_map.
-
#apply(val = Undefined, &block) ⇒ Object
private
Applies another Valid to the stored function.
-
#fmap(proc = Undefined, &block) ⇒ Object
private
Lifts a block/proc over Valid.
-
#initialize(value) ⇒ Valid
constructor
private
A new instance of Valid.
- #inspect ⇒ String (also: #to_s) private
-
#or(_ = nil) ⇒ Validated::Valid
private
Ignores arguments, returns self.
-
#to_maybe ⇒ Maybe::Some
Converts to Maybe::Some.
-
#to_result ⇒ Result::Success
Converts to Result::Success.
-
#value! ⇒ Object
private
Extracts the value.
Methods inherited from Dry::Monads::Validated
Constructor Details
#initialize(value) ⇒ Valid
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 Valid.
59 60 61 62 63 |
# File 'lib/dry/monads/validated.rb', line 59 def initialize(value) super() @value = value 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.
133 134 135 |
# File 'lib/dry/monads/validated.rb', line 133 def ===(other) other.instance_of?(self.class) && value! === other.value! end |
#alt_map(_ = nil) ⇒ Validated::Valid
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 values and returns self, see Invalid#alt_map
110 111 112 |
# File 'lib/dry/monads/validated.rb', line 110 def alt_map(_ = nil) self end |
#apply(val) ⇒ Validated::Valid, Validated::Invalid #apply ⇒ Validated::Valid, 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.
Applies another Valid to the stored function
88 89 90 |
# File 'lib/dry/monads/validated.rb', line 88 def apply(val = Undefined, &block) Undefined.default(val, &block).fmap(Curry.(value!)) end |
#fmap(proc) ⇒ Validated::Valid #fmap ⇒ Validated::Valid
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 Valid
102 103 104 105 |
# File 'lib/dry/monads/validated.rb', line 102 def fmap(proc = Undefined, &block) f = Undefined.default(proc, block) self.class.new(f.(value!)) 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.
122 123 124 125 126 127 128 |
# File 'lib/dry/monads/validated.rb', line 122 def inspect if Unit.equal?(@value) "Valid()" else "Valid(#{@value.inspect})" end end |
#or(_ = nil) ⇒ Validated::Valid
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 arguments, returns self
117 118 119 |
# File 'lib/dry/monads/validated.rb', line 117 def or(_ = nil) self end |
#to_maybe ⇒ Maybe::Some
Converts to Maybe::Some
436 437 438 |
# File 'lib/dry/monads/maybe.rb', line 436 def to_maybe Maybe.pure(value!) end |
#to_result ⇒ Result::Success
Converts to Result::Success
463 464 465 |
# File 'lib/dry/monads/result.rb', line 463 def to_result Result.pure(value!) end |
#value! ⇒ 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.
Extracts the value
68 69 70 |
# File 'lib/dry/monads/validated.rb', line 68 def value! @value end |