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.
240 |
# File 'lib/dry/monads/right_biased.rb', line 240 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.
322 |
# File 'lib/dry/monads/right_biased.rb', line 322 def and(_, &) = self |
#apply ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
304 |
# File 'lib/dry/monads/right_biased.rb', line 304 def apply(...) = self |
#bind ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
249 |
# File 'lib/dry/monads/right_biased.rb', line 249 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
339 340 341 342 343 344 345 346 347 |
# File 'lib/dry/monads/right_biased.rb', line 339 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
358 359 360 361 362 363 364 |
# File 'lib/dry/monads/right_biased.rb', line 358 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.
310 |
# File 'lib/dry/monads/right_biased.rb', line 310 def discard = self |
#flatten ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
316 |
# File 'lib/dry/monads/right_biased.rb', line 316 def flatten = self |
#fmap ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
261 |
# File 'lib/dry/monads/right_biased.rb', line 261 def fmap(...) = self |
#or ⇒ Object
Left-biased #bind version.
271 |
# File 'lib/dry/monads/right_biased.rb', line 271 def or(...) = raise NotImplementedError |
#or_fmap ⇒ RightBiased::Left, RightBiased::Right
A lifted version of ‘#or`. This is basically `#or` + `#fmap`.
287 |
# File 'lib/dry/monads/right_biased.rb', line 287 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.
255 |
# File 'lib/dry/monads/right_biased.rb', line 255 def tee(...) = self |
#value! ⇒ Object
Raises an error on accessing internal value
243 |
# File 'lib/dry/monads/right_biased.rb', line 243 def value! = raise UnwrapError, self |
#value_or(val = nil) ⇒ Object
Returns the passed value
292 293 294 295 296 297 298 |
# File 'lib/dry/monads/right_biased.rb', line 292 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#|.
278 |
# File 'lib/dry/monads/right_biased.rb', line 278 def |(alt) = self.or(alt) |