Class: CarryOut::Plan::NodeContext
- Inherits:
-
Object
- Object
- CarryOut::Plan::NodeContext
show all
- Includes:
- Cloaker
- Defined in:
- lib/carry_out/plan/node_context.rb
Instance Method Summary
collapse
Methods included from Cloaker
#cloaker, #with_previous_context
Constructor Details
Returns a new instance of NodeContext.
8
9
10
|
# File 'lib/carry_out/plan/node_context.rb', line 8
def initialize(node)
@node = node
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/carry_out/plan/node_context.rb', line 30
def method_missing(method, *args, &block)
if @node.respond_to?(method)
@node.send(method, *args, &block)
else
super
end
end
|
Instance Method Details
#action ⇒ Object
12
13
14
|
# File 'lib/carry_out/plan/node_context.rb', line 12
def action
self
end
|
#context(*args) ⇒ Object
16
17
18
19
20
|
# File 'lib/carry_out/plan/node_context.rb', line 16
def context(*args)
Proc.new do |context|
args.inject(context) { |c, k| c.nil? ? nil : c[k] }
end
end
|
#except_when(value = nil, &block) ⇒ Object
26
27
28
|
# File 'lib/carry_out/plan/node_context.rb', line 26
def except_when(value = nil, &block)
@node.guard_with_inverse(value || block)
end
|
#only_when(value = nil, &block) ⇒ Object
22
23
24
|
# File 'lib/carry_out/plan/node_context.rb', line 22
def only_when(value = nil, &block)
@node.guard_with(value || block)
end
|
#respond_to?(method) ⇒ Boolean
38
39
40
|
# File 'lib/carry_out/plan/node_context.rb', line 38
def respond_to?(method)
@node.respond_to?(method)
end
|
#return_as(key, &block) ⇒ Object
42
43
44
45
|
# File 'lib/carry_out/plan/node_context.rb', line 42
def return_as(key, &block)
@node.returns_as = key
@node.return_transform = block unless block.nil?
end
|