Class: CarryOut::Plan::Guard
- Inherits:
-
Object
- Object
- CarryOut::Plan::Guard
- Defined in:
- lib/carry_out/plan/guard.rb
Instance Method Summary collapse
- #call(context = {}) ⇒ Object
-
#initialize(proc, options = {}) ⇒ Guard
constructor
A new instance of Guard.
- #invert(is_inverted = true) ⇒ Object
Constructor Details
#initialize(proc, options = {}) ⇒ Guard
Returns a new instance of Guard.
6 7 8 9 |
# File 'lib/carry_out/plan/guard.rb', line 6 def initialize(proc, = {}) @proc = proc invert([:invert]) end |
Instance Method Details
#call(context = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/carry_out/plan/guard.rb', line 11 def call(context = {}) result = GuardContext.new(context).instance_exec(context, &@proc) result = !result if @invert result end |
#invert(is_inverted = true) ⇒ Object
17 18 19 |
# File 'lib/carry_out/plan/guard.rb', line 17 def invert(is_inverted = true) @invert = !!is_inverted end |