Sha256: 133ceb3a4277d0649de0b066ec282f3d57bee3e9a06da41638c0f85bb84036ed

Contents?: true

Size: 764 Bytes

Versions: 4

Compression:

Stored size: 764 Bytes

Contents

module Queuel
  module Base
    class Engine
      extend Introspect
      def self.inherited(klass)
        klass.class_eval do
          def queue_klass
            self.class.const_with_nesting "Queue"
          end
        end
      end

      def initialize(credentials = {})
        self.credentials = credentials
        self.memoized_queues = {}
      end

      def queue(which_queue)
        memoized_queues[which_queue.to_s] ||= queue_klass.new(client, which_queue)
      end

      private
      attr_accessor :credentials
      attr_accessor :memoized_queues

      def client
        @client ||= client_klass.new credentials
      end

      def client_klass
        raise NotImplementedError, "Must define a Queue class"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
queuel-0.3.1 lib/queuel/base/engine.rb
queuel-0.3.0 lib/queuel/base/engine.rb
queuel-0.2.0 lib/queuel/base/engine.rb
queuel-0.1.0 lib/queuel/base/engine.rb