Module: Fear::For::Mixin

Included in:
Mixin
Defined in:
lib/fear/for.rb

Overview

Include this mixin to access convenient factory method for For.

Examples:

include Fear::For::Mixin

For(a: Some(2), b: Some(3)) { a * b }   #=> Some(6)
For(a: Some(2), b: None()) { a * b }    #=> None()

For(a: Right(2), b: Right(3)) { a * b } #=> Right(6)
For(a: Right(2), b: Left(3)) { a * b }  #=> Left(3)

For(a: Success(2), b: Success(3)) { a * b }    #=> Success(3)
For(a: Success(2), b: Failure(...)) { a * b }  #=> Failure(...)

Instance Method Summary collapse

Instance Method Details

#For(**locals, &block) ⇒ {#map, #flat_map}

Parameters:

  • locals (Hash{Symbol => {#map, #flat_map}})

Returns:

  • ({#map, #flat_map})


114
115
116
# File 'lib/fear/for.rb', line 114

def For(**locals, &block)
  For.new(**locals).call(&block)
end