Class: Dry::Monads::Maybe::Some
- Inherits:
-
Dry::Monads::Maybe
- Object
- Dry::Monads::Maybe
- Dry::Monads::Maybe::Some
- Includes:
- RightBiased::Right
- Defined in:
- lib/dry/monads/maybe.rb
Overview
Represents a value that is present, i.e. not nil.
Instance Method Summary collapse
-
#fmap(*args, &block) ⇒ Maybe::Some, Maybe::None
Does the same thing as #bind except it also wraps the value in an instance of Maybe::Some monad.
-
#initialize(value = Undefined) ⇒ Some
constructor
A new instance of Some.
- #to_s ⇒ String (also: #inspect)
Methods included from RightBiased::Right
#===, #apply, #bind, #discard, included, #or, #or_fmap, #tee, #value!, #value_or
Methods inherited from Dry::Monads::Maybe
#as_json, coerce, json_create, #monad, #none?, pure, #some?, #to_json, #to_maybe, #to_monad, to_proc
Methods included from Transformer
Constructor Details
Instance Method Details
#fmap(*args, &block) ⇒ Maybe::Some, Maybe::None
Does the same thing as #bind except it also wraps the value in an instance of Maybe::Some monad. This allows for easier chaining of calls.
106 107 108 |
# File 'lib/dry/monads/maybe.rb', line 106 def fmap(*args, &block) self.class.coerce(bind(*args, &block)) end |
#to_s ⇒ String Also known as: inspect
111 112 113 |
# File 'lib/dry/monads/maybe.rb', line 111 def to_s "Some(#{ @value.inspect })" end |