Sha256: c73d3dcab2bc4836bea5f9bcea04a55dc10224489ab54f9eca7512cb73f15ffa

Contents?: true

Size: 855 Bytes

Versions: 6853

Compression:

Stored size: 855 Bytes

Contents

module Typhoeus
  class Hydra

    # This module provides a way to hook into before
    # a request gets queued in hydra. This is very powerful
    # and you should be careful because when you accidently
    # return a falsy value the request won't be executed.
    #
    # @api private
    module Before

      # Overrride add in order to execute callbacks in
      # Typhoeus.before. Will break and return when a
      # callback returns nil, false or a response. Calls super
      # otherwise.
      #
      # @example Add the request.
      #   hydra.add(request)
      def add(request)
        Typhoeus.before.each do |callback|
          value = callback.call(request)
          if value.nil? || value == false || value.is_a?(Response)
            dequeue
            return value
          end
        end
        super
      end
    end
  end
end

Version data entries

6,853 entries across 6,850 versions & 28 rubygems

Version Path
cloudsmith-api-0.54.15 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.53.79 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.53.17 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.53.3 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.53.1 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.52.121 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.52.92 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.52.79 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.52.5 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.52.0 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.51.93 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.51.38 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.51.37 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.51.34 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.51.22 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb
typhoeus-1.4.0 lib/typhoeus/hydra/before.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.1/lib/typhoeus/hydra/before.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/typhoeus-1.3.1/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.49.118 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/hydra/before.rb
cloudsmith-api-0.49.98 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/hydra/before.rb