Sha256: 68a94faea994587f7da7af0eb1d5518bef6650e564ff83273a5a2f95244146e7

Contents?: true

Size: 443 Bytes

Versions: 3

Compression:

Stored size: 443 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Middleware
    class Dispatch
      extend Base

      def call(task)
        controller = task.metadata.controller

        controller.run_callbacks(:action) do
          case action = task.metadata.action
          when Symbol then controller.public_send(action)
          else action.new.call(task)
          end
        end

        yield if block_given?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wayfarer-0.4.6 lib/wayfarer/middleware/dispatch.rb
wayfarer-0.4.5 lib/wayfarer/middleware/dispatch.rb
wayfarer-0.4.4 lib/wayfarer/middleware/dispatch.rb