lib/wayfarer/middleware/dispatch.rb in wayfarer-0.4.6 vs lib/wayfarer/middleware/dispatch.rb in wayfarer-0.4.7
- old
+ new
@@ -4,15 +4,23 @@
module Middleware
class Dispatch
extend Base
def call(task)
- controller = task.metadata.controller
+ controller = task[:controller]
- controller.run_callbacks(:action) do
- case action = task.metadata.action
+ task[:return_value] = controller.run_callbacks(:action) do
+ case action = task[:action]
when Symbol then controller.public_send(action)
- else action.new.call(task)
+ when Array
+ handler, method = action
+ task[:action] = method
+ handler.new.call(task)
+ else
+ raise ArgumentError, "invalid action: #{action.inspect}" unless action&.include?(Wayfarer::Handler)
+
+ task[:action] = nil # TODO: Test
+ action.new.call(task)
end
end
yield if block_given?
end