class HTTParty::HeadersProcessor

Attributes

headers[R]
options[R]

Public Class Methods

new(headers, options) click to toggle source
# File lib/httparty/headers_processor.rb, line 7
def initialize(headers, options)
  @headers = headers
  @options = options
end

Public Instance Methods

call() click to toggle source
# File lib/httparty/headers_processor.rb, line 12
def call
  return unless options[:headers]

  options[:headers] = headers.merge(options[:headers]) if headers.any?
  options[:headers] = Utils.stringify_keys(process_dynamic_headers)
end

Private Instance Methods

process_dynamic_headers() click to toggle source
# File lib/httparty/headers_processor.rb, line 21
def process_dynamic_headers
  options[:headers].each_with_object({}) do |header, processed_headers|
    key, value = header
    processed_headers[key] = if value.respond_to?(:call)
                               value.arity == 0 ? value.call : value.call(options)
                             else
                               value
                             end
  end
end