Module: Dry::Monads::RightBiased::Left
- Included in:
- Maybe::None, Dry::Monads::Result::Failure, Try::Error
- Defined in:
- lib/dry/monads/right_biased.rb
Overview
Left/wrong/erroneous part
Class Method Summary collapse
-
.trace_caller ⇒ String
Caller location.
Instance Method Summary collapse
-
#and(_) ⇒ RightBiased::Left
Returns self back.
-
#apply ⇒ RightBiased::Left
Ignores the input parameter and returns self.
-
#bind ⇒ RightBiased::Left
Ignores the input parameter and returns self.
-
#deconstruct ⇒ Object
private
Pattern matching.
-
#deconstruct_keys(keys) ⇒ Object
private
Pattern matching hash values.
-
#discard ⇒ RightBiased::Left
Returns self back.
-
#flatten ⇒ RightBiased::Left
Returns self back.
-
#fmap ⇒ RightBiased::Left
Ignores the input parameter and returns self.
-
#or ⇒ Object
Left-biased #bind version.
-
#or_fmap ⇒ RightBiased::Left, RightBiased::Right
A lifted version of ‘#or`.
-
#tee ⇒ RightBiased::Left
Ignores the input parameter and returns self.
-
#value! ⇒ Object
Raises an error on accessing internal value.
-
#value_or(val = nil) ⇒ Object
Returns the passed value.
-
#|(alt) ⇒ RightBiased::Right, RightBiased::Left
Returns the passed value.
Class Method Details
.trace_caller ⇒ String
Returns Caller location.
237 |
# File 'lib/dry/monads/right_biased.rb', line 237 def self.trace_caller = caller_locations(2, 1)[0].to_s |
Instance Method Details
#and(_) ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
319 |
# File 'lib/dry/monads/right_biased.rb', line 319 def and(_, &) = self |
#apply ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
301 |
# File 'lib/dry/monads/right_biased.rb', line 301 def apply(...) = self |
#bind ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
246 |
# File 'lib/dry/monads/right_biased.rb', line 246 def bind(...) = self |
#deconstruct ⇒ 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.
Pattern matching
332 333 334 335 336 337 338 339 340 |
# File 'lib/dry/monads/right_biased.rb', line 332 def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end |
#deconstruct_keys(keys) ⇒ 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.
Pattern matching hash values
351 352 353 354 355 356 357 |
# File 'lib/dry/monads/right_biased.rb', line 351 def deconstruct_keys(keys) if @value.respond_to?(:deconstruct_keys) @value.deconstruct_keys(keys) else EMPTY_HASH end end |
#discard ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
307 |
# File 'lib/dry/monads/right_biased.rb', line 307 def discard = self |
#flatten ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
313 |
# File 'lib/dry/monads/right_biased.rb', line 313 def flatten = self |
#fmap ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
258 |
# File 'lib/dry/monads/right_biased.rb', line 258 def fmap(...) = self |
#or ⇒ Object
Left-biased #bind version.
268 |
# File 'lib/dry/monads/right_biased.rb', line 268 def or(...) = raise NotImplementedError |
#or_fmap ⇒ RightBiased::Left, RightBiased::Right
A lifted version of ‘#or`. This is basically `#or` + `#fmap`.
284 |
# File 'lib/dry/monads/right_biased.rb', line 284 def or_fmap(...) = raise NotImplementedError |
#tee ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
252 |
# File 'lib/dry/monads/right_biased.rb', line 252 def tee(...) = self |
#value! ⇒ Object
Raises an error on accessing internal value
240 |
# File 'lib/dry/monads/right_biased.rb', line 240 def value! = raise UnwrapError, self |
#value_or(val = nil) ⇒ Object
Returns the passed value
289 290 291 292 293 294 295 |
# File 'lib/dry/monads/right_biased.rb', line 289 def value_or(val = nil) if block_given? yield else val end end |
#|(alt) ⇒ RightBiased::Right, RightBiased::Left
Returns the passed value. Works in pair with Right#|.
275 |
# File 'lib/dry/monads/right_biased.rb', line 275 def |(alt) = self.or(alt) |