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(_) ⇒ 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.
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, 2)[0].to_s end |
Instance Method Details
#and(_) ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
350 351 352 |
# File 'lib/dry/monads/right_biased.rb', line 350 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.
326 327 328 |
# File 'lib/dry/monads/right_biased.rb', line 326 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
365 366 367 368 369 370 371 372 373 |
# File 'lib/dry/monads/right_biased.rb', line 365 def deconstruct if Unit.equal?(@value) [] elsif @value.is_a?(::Array) @value else [@value] end end |
#deconstruct_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
384 385 386 387 388 389 390 |
# File 'lib/dry/monads/right_biased.rb', line 384 def deconstruct_keys(_) if @value.is_a?(::Hash) @value else EMPTY_HASH end end |
#discard ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
334 335 336 |
# File 'lib/dry/monads/right_biased.rb', line 334 def discard self end |
#flatten ⇒ RightBiased::Left
Returns self back. It exists to keep the interface identical to that of Right.
342 343 344 |
# File 'lib/dry/monads/right_biased.rb', line 342 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
.
307 308 309 |
# File 'lib/dry/monads/right_biased.rb', line 307 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.new(self) end |
#value_or(val = nil) ⇒ Object
Returns the passed value
314 315 316 317 318 319 320 |
# File 'lib/dry/monads/right_biased.rb', line 314 def value_or(val = nil) if block_given? yield else val end end |