This file is indexed.

/usr/lib/ruby/vendor_ruby/typhoeus/hydra/memoizable.rb is in ruby-typhoeus 0.6.8-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module Typhoeus
  class Hydra

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

      # Return the memory.
      #
      # @example Return the memory.
      #   hydra.memory
      #
      # @return [ Hash ] The memory.
      def memory
        @memory ||= {}
      end

      # 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.
      #
      # @example Add the request.
      #   hydra.add(request)
      #
      # @param [ Request ] request The request to add.
      #
      # @return [ Request ] The added request.
      def add(request)
        if request.memoizable? && memory.has_key?(request)
          response = memory[request]
          request.finish(response, true)
          dequeue
        else
          super
        end
      end

      # Overrides run to make sure the memory is cleared after
      # each run.
      #
      # @example Run hydra.
      #   hydra.run
      def run
        super
        memory.clear
      end
    end
  end
end