Module: Waterfall
- Included in:
- Wf
- Defined in:
- lib/waterfall.rb,
lib/waterfall/version.rb,
lib/waterfall/predicates/base.rb,
lib/waterfall/predicates/chain.rb,
lib/waterfall/predicates/on_dam.rb,
lib/waterfall/predicates/when_falsy.rb,
lib/waterfall/predicates/when_truthy.rb
Defined Under Namespace
Classes: Base, Chain, IncorrectChainingArgumentError, IncorrectDamArgumentError, OnDam, WhenFalsy, WhenTruthy
Constant Summary
collapse
- VERSION =
"1.2.0"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#error_pool ⇒ Object
Returns the value of attribute error_pool.
11
12
13
|
# File 'lib/waterfall.rb', line 11
def error_pool
@error_pool
end
|
#outflow ⇒ Object
Returns the value of attribute outflow.
11
12
13
|
# File 'lib/waterfall.rb', line 11
def outflow
@outflow
end
|
Instance Method Details
#chain(mapping_or_var_name = nil, &block) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/waterfall.rb', line 28
def chain(mapping_or_var_name = nil, &block)
_wf_run do
::Waterfall::Chain
.new(self, mapping_or_var_name)
.call(&block)
end
end
|
#dam(obj) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/waterfall.rb', line 43
def dam(obj)
raise IncorrectDamArgumentError.new("You cant dam with a falsy object") unless obj
_wf_run do
@error_pool = obj
_reverse_flows(true)
end
end
|
#dammed? ⇒ Boolean
55
56
57
|
# File 'lib/waterfall.rb', line 55
def dammed?
!error_pool.nil?
end
|
#halt_chain {|outflow, error_pool| ... } ⇒ Object
51
52
53
|
# File 'lib/waterfall.rb', line 51
def halt_chain(&block)
yield(outflow, error_pool)
end
|
#has_flown? ⇒ Boolean
63
64
65
|
# File 'lib/waterfall.rb', line 63
def has_flown?
!! @has_flown
end
|
#is_waterfall? ⇒ Boolean
59
60
61
|
# File 'lib/waterfall.rb', line 59
def is_waterfall?
true
end
|
#on_dam(&block) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/waterfall.rb', line 36
def on_dam(&block)
::Waterfall::OnDam
.new(self)
.call(&block)
self
end
|
#reverse_flow ⇒ Object
72
73
|
# File 'lib/waterfall.rb', line 72
def reverse_flow
end
|
#update_outflow(key, value) ⇒ Object
67
68
69
70
|
# File 'lib/waterfall.rb', line 67
def update_outflow(key, value)
@outflow[key] = value
self
end
|
#when_falsy(&block) ⇒ Object
16
17
18
19
20
|
# File 'lib/waterfall.rb', line 16
def when_falsy(&block)
::Waterfall::WhenFalsy.new(self).tap do |handler|
_wf_run { handler.call(&block) }
end
end
|
#when_truthy(&block) ⇒ Object
22
23
24
25
26
|
# File 'lib/waterfall.rb', line 22
def when_truthy(&block)
::Waterfall::WhenTruthy.new(self).tap do |handler|
_wf_run { handler.call(&block) }
end
end
|