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) ⇒ 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.
57 58 59 60 61 |
# File 'lib/dry/monads/validated.rb', line 57 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.
125 126 127 |
# File 'lib/dry/monads/validated.rb', line 125 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
106 |
# File 'lib/dry/monads/validated.rb', line 106 def alt_map(_ = nil, &) = self |
#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
84 85 86 |
# File 'lib/dry/monads/validated.rb', line 84 def apply(val = Undefined, &) Undefined.default(val, &).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
98 99 100 101 |
# File 'lib/dry/monads/validated.rb', line 98 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.
114 115 116 117 118 119 120 |
# File 'lib/dry/monads/validated.rb', line 114 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
111 |
# File 'lib/dry/monads/validated.rb', line 111 def or(_ = nil, &) = self |
#to_maybe ⇒ Maybe::Some
Converts to Maybe::Some
401 |
# File 'lib/dry/monads/maybe.rb', line 401 def to_maybe = Maybe.pure(value!) |
#to_result ⇒ Result::Success
Converts to Result::Success
425 |
# File 'lib/dry/monads/result.rb', line 425 def to_result = Result.pure(value!) |
#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
66 |
# File 'lib/dry/monads/validated.rb', line 66 def value! = @value |