Sha256: 7ae5bbce0eb6a2fac8aa4acd2cbd20ff7476de1307533d817c79d8838d38b7a0

Contents?: true

Size: 979 Bytes

Versions: 6865

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,865 entries across 6,862 versions & 28 rubygems

Version Path
cloudsmith-api-0.49.98 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.49.94 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.49.21 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.49.15 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.49.13 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.49.9 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.44.4 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.0/lib/typhoeus/request/memoizable.rb
approveapi-1.0.8 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
approveapi-1.0.5 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/memoizable.rb
typhoeus-1.3.1 lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.0/lib/typhoeus/request/memoizable.rb
color_me_shop-1.0.0 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.3.0/lib/typhoeus/request/memoizable.rb
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.0/lib/typhoeus/request/memoizable.rb
typhoeus-1.3.0 lib/typhoeus/request/memoizable.rb
typhoeus-1.1.2 lib/typhoeus/request/memoizable.rb
typhoeus-1.1.1 lib/typhoeus/request/memoizable.rb
typhoeus-1.1.0 lib/typhoeus/request/memoizable.rb
typhoeus-1.0.2 lib/typhoeus/request/memoizable.rb
typhoeus-1.0.1 lib/typhoeus/request/memoizable.rb