Sha256: 7ae5bbce0eb6a2fac8aa4acd2cbd20ff7476de1307533d817c79d8838d38b7a0

Contents?: true

Size: 979 Bytes

Versions: 6820

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,820 entries across 6,817 versions & 27 rubygems

Version Path
cybrid_api_id_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_bank_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_id_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_organization_ruby-0.123.123 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_bank_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_organization_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_id_ruby-0.123.122 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_bank_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_id_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_organization_ruby-0.123.121 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_bank_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_organization_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_id_ruby-0.123.120 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_bank_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_organization_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_id_ruby-0.123.119 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_bank_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_id_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_organization_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb
cybrid_api_bank_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/memoizable.rb