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.
255 256 257 |
# File 'lib/dry/monads/right_biased.rb', line 255 def self.trace_caller caller_locations(2, 1)[0].to_s end |
Instance Method Details
#and(_) ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
359 360 361 |
# File 'lib/dry/monads/right_biased.rb', line 359 def and(_) self end |
#apply ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
335 336 337 |
# File 'lib/dry/monads/right_biased.rb', line 335 def apply(*) self end |
#bind ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
268 269 270 |
# File 'lib/dry/monads/right_biased.rb', line 268 def bind(*) self end |
#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
374 375 376 377 378 379 380 381 382 |
# File 'lib/dry/monads/right_biased.rb', line 374 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
393 394 395 396 397 398 399 |
# File 'lib/dry/monads/right_biased.rb', line 393 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.
343 344 345 |
# File 'lib/dry/monads/right_biased.rb', line 343 def discard self end |
#flatten ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
351 352 353 |
# File 'lib/dry/monads/right_biased.rb', line 351 def flatten self end |
#fmap ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
284 285 286 |
# File 'lib/dry/monads/right_biased.rb', line 284 def fmap(*) self end |
#or ⇒ Object
Left-biased #bind version.
296 297 298 |
# File 'lib/dry/monads/right_biased.rb', line 296 def or(*) raise NotImplementedError end |
#or_fmap ⇒ RightBiased::Left, RightBiased::Right
A lifted version of ‘#or`. This is basically `#or` + `#fmap`.
316 317 318 |
# File 'lib/dry/monads/right_biased.rb', line 316 def or_fmap(*) raise NotImplementedError end |
#tee ⇒ RightBiased::Left
Ignores the input parameter and returns self. It exists to keep the interface identical to that of Right.
276 277 278 |
# File 'lib/dry/monads/right_biased.rb', line 276 def tee(*) self end |
#value! ⇒ Object
Raises an error on accessing internal value
260 261 262 |
# File 'lib/dry/monads/right_biased.rb', line 260 def value! raise UnwrapError, self end |
#value_or(val = nil) ⇒ Object
Returns the passed value
323 324 325 326 327 328 329 |
# File 'lib/dry/monads/right_biased.rb', line 323 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#|.
305 306 307 |
# File 'lib/dry/monads/right_biased.rb', line 305 def |(alt) self.or(alt) end |