Sha256: 7ae5bbce0eb6a2fac8aa4acd2cbd20ff7476de1307533d817c79d8838d38b7a0

Contents?: true

Size: 979 Bytes

Versions: 6864

Compression:

Stored size: 979 Bytes

Contents

module Typhoeus
  class Request

    # This module handles the GET request memoization
    # on the request side. Memoization needs to be turned
    # on:
    #   Typhoeus.configure do |config|
    #     config.memoize = true
    #   end
    #
    # @api private
    module Memoizable

      # Override response setter and memoizes response
      # if the request is memoizable.
      #
      # @param [ Response ] response The response to set.
      #
      # @example Set response.
      #   request.response = response
      def response=(response)
        hydra.memory[self] = response if memoizable?
        super
      end

      # Return whether a request is memoizable.
      #
      # @example Is request memoizable?
      #   request.memoizable?
      #
      # @return [ Boolean ] Return true if memoizable, false else.
      def memoizable?
        Typhoeus::Config.memoize &&
          (options[:method].nil? || options[:method] == :get)
      end
    end
  end
end

Version data entries

6,864 entries across 6,861 versions & 28 rubygems

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