Sha256: 63e2019c502ffbb34590f2dde1a6b8b376111f4a36513ba413085c33ac739d67
Contents?: true
Size: 687 Bytes
Versions: 2
Compression:
Stored size: 687 Bytes
Contents
module RestfulResource class Request attr_reader :body, :method, :url def initialize(method, url, headers: {}, body: nil) @method, @url, @headers, @body = method, url, headers, body end def headers default_headers.merge(format_headers) end private # Formats all keys in Word-Word format def format_headers @headers.stringify_keys.inject({}) do |h, key_with_value| h[format_key key_with_value.first] = key_with_value.last h end end def format_key(key) key.humanize.split(' ').map(&:humanize).join('-') end def default_headers { 'Accept' => 'application/json' } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
restful_resource-2.0.2 | lib/restful_resource/request.rb |
restful_resource-2.0.1 | lib/restful_resource/request.rb |