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/wayfarer/middleware/dispatch.rb', line 10
def call(task)
controller = task[:controller]
task[:return_value] = controller.run_callbacks(:action) do
case action = task[:action]
when Symbol then controller.public_send(action)
when Array
handler, method = action
task[:action] = method
handler.new.call(task)
else
unless action&.include?(Wayfarer::Handler)
raise InvalidTargetError, "routed to invalid action: #{action.inspect}"
end
task[:action] = nil
action.new.call(task)
end
end
yield if block_given?
end
|