Module: Typhoeus::Hydra::Memoizable Private
- Included in:
- Typhoeus::Hydra
- Defined in:
- lib/typhoeus/hydra/memoizable.rb
Overview
Instance Method Summary collapse
-
#add(request) ⇒ Request
private
Overrides add in order to check before if request is memoizable and already in memory.
-
#memory ⇒ Hash
private
Return the memory.
-
#run ⇒ Object
private
Overrides run to make sure the memory is cleared after each run.
Instance Method Details
#add(request) ⇒ Request
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.
Overrides add in order to check before if request is memoizable and already in memory. If thats the case, super is not called, instead the response is set and the on_complete callback called.
35 36 37 38 39 40 41 42 43 |
# File 'lib/typhoeus/hydra/memoizable.rb', line 35 def add(request) if request.memoizable? && memory.has_key?(request) response = memory[request] request.finish(response, true) dequeue else super end end |
#memory ⇒ Hash
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 the memory.
20 21 22 |
# File 'lib/typhoeus/hydra/memoizable.rb', line 20 def memory @memory ||= {} end |
#run ⇒ 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.
Overrides run to make sure the memory is cleared after each run.
50 51 52 53 |
# File 'lib/typhoeus/hydra/memoizable.rb', line 50 def run super memory.clear end |