Module: Typhoeus::Request::Memoizable Private

Included in:
Typhoeus::Request
Defined in:
lib/typhoeus/request/memoizable.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#memoizable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return whether a request is memoizable.

Examples:

Is request memoizable?

request.memoizable?

Returns:

  • (Boolean)

    Return true if memoizable, false else.

Since:

  • 0.5.0



32
33
34
35
# File 'lib/typhoeus/request/memoizable.rb', line 32

def memoizable?
  Typhoeus::Config.memoize &&
    (options[:method].nil? || options[:method] == :get)
end

#response=(response) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Override response setter and memoizes response if the request is memoizable.

Examples:

Set response.

request.response = response

Parameters:

  • response (Response)

    The response to set.

Since:

  • 0.5.0



21
22
23
24
# File 'lib/typhoeus/request/memoizable.rb', line 21

def response=(response)
  hydra.memory[self] = response if memoizable?
  super
end