Sha256: 4a32dd3b68f8f709735b5d26daac806a602578a17de8c569bdc176f22e511c11

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Middleware
    module Worker
      def self.included(base)
        base.include(Wayfarer::Redis::Connection)
        base.include(Wayfarer::Middleware::Stage::API)
        base.include(Wayfarer::Middleware::Router::API)
        base.include(Wayfarer::Middleware::Fetch::API)
        base.include(Wayfarer::Callbacks)
        base.include(InstanceMethods)
      end

      module InstanceMethods
        def call(task)
          run_callbacks :action do
            public_send(task.metadata.action)
          end

          yield if block_given?
        end

        def chain
          Wayfarer::Middleware::Chain.new([*Wayfarer.middleware, self])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wayfarer-0.4.3 lib/wayfarer/middleware/worker.rb
wayfarer-0.4.2 lib/wayfarer/middleware/worker.rb