7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/emit/alternation.rb', line 7
def execute
idx, request, channel, operation = choose
if @guards[idx]
action = @guards[idx].last[:action]
case action
when Choice
case operation
when :write then action.invoke_on_output
when :read then action.invoke_on_input(request.message)
end
when Proc, Method
case operation
when :write then action.()
when :read then action.(message: request.message)
end
when nil
else
fail "Failed executing action: #{action}."
end
end
[channel, request.message]
end
|