Class: Eventually

Inherits:
Struct show all
Includes:
Monad
Defined in:
lib/maybe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Monad

#within

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



45
46
47
# File 'lib/maybe.rb', line 45

def block
  @block
end

Instance Method Details

#and_then(&block) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/maybe.rb', line 46

def and_then(&block)
  Eventually.new do |success|
    run do |value|
      block.call(value).run(&success)
    end
  end
end