Sha256: 2919067aa8ff3c981d23cfb8f3d45bc8e65352264827b3de08c1855968d2fd6e

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

module Typhoeus
  class Hydra

    # This module handles the request queueing on
    # hydra.
    #
    # @api private
    module Queueable

      # Return the queued requests.
      #
      # @example Return queued requests.
      #  hydra.queued_requests
      #
      # @return [ Array<Typhoeus::Request> ] The queued requests.
      def queued_requests
        @queued_requests ||= []
      end

      # Abort the current hydra run as good as
      # possible. This means that it only
      # clears the queued requests and can't do
      # anything about already running requests.
      #
      # @example Abort hydra.
      #  hydra.abort
      def abort
        queued_requests.clear
      end

      # Enqueues a request in order to be performed
      # by the hydra. This can even be done while
      # the hydra is running. Also sets hydra on
      # request.
      #
      # @example Queue request.
      #  hydra.queue(request)
      def queue(request)
        request.hydra = self
        queued_requests << request
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typhoeus-0.6.3 lib/typhoeus/hydra/queueable.rb
typhoeus-0.6.2 lib/typhoeus/hydra/queueable.rb
typhoeus-0.6.1 lib/typhoeus/hydra/queueable.rb
typhoeus-0.6.0 lib/typhoeus/hydra/queueable.rb
typhoeus-0.6 lib/typhoeus/hydra/queueable.rb
typhoeus-0.5.4 lib/typhoeus/hydra/queueable.rb
typhoeus-0.5.3 lib/typhoeus/hydra/queueable.rb
typhoeus-0.5.2 lib/typhoeus/hydra/queueable.rb