Class: Waterfall::WhenTruthy

Inherits:
Base
  • Object
show all
Defined in:
lib/waterfall/predicates/when_truthy.rb

Direct Known Subclasses

WhenFalsy

Instance Method Summary collapse

Methods inherited from Base

#waterfall?, #yield_args

Constructor Details

#initialize(root) ⇒ WhenTruthy

Returns a new instance of WhenTruthy.



4
5
6
# File 'lib/waterfall/predicates/when_truthy.rb', line 4

def initialize(root)
  @root = root
end

Instance Method Details

#callObject



8
9
10
# File 'lib/waterfall/predicates/when_truthy.rb', line 8

def call
  @output = yield(*yield_args)
end

#condition?Boolean

Returns:



19
20
21
# File 'lib/waterfall/predicates/when_truthy.rb', line 19

def condition?
  @output
end

#damObject



12
13
14
15
16
17
# File 'lib/waterfall/predicates/when_truthy.rb', line 12

def dam
  if !@root.dammed? && condition?
    @root.dam yield(*yield_args)
  end
  @root
end