Sha256: 13c117567e4fd60ca12e6b7ca486ff9ba2d4997d8f91e2bc832ec0ddc03a1c90
Contents?: true
Size: 951 Bytes
Versions: 2
Compression:
Stored size: 951 Bytes
Contents
module Pacto module Extensions # Adapted from Faraday HeaderKeyMap = Hash.new do |map, key| split_char = key.to_s.include?('-') ? '-' : '_' map[key] = key.to_s.split(split_char). # :user_agent => %w(user agent) each { |w| w.capitalize! }. # => %w(User Agent) join('-') # => "User-Agent" end HeaderKeyMap[:etag] = 'ETag' def self.normalize_header_keys(headers) headers.reduce({}) do |normalized, (key, value)| normalized[HeaderKeyMap[key]] = value normalized end end module HashSubsetOf # FIXME: Only used by HashMergeProcessor, which I'd like to deprecate def normalize_keys reduce({}) do |normalized, (key, value)| normalized[key.to_s.downcase] = value normalized end end end end end # FIXME: Let's not extend Hash... Hash.send(:include, Pacto::Extensions::HashSubsetOf)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.3.1 | lib/pacto/extensions.rb |
pacto-0.3.0 | lib/pacto/extensions.rb |