class RestfulResource::Request
Attributes
body[R]
method[R]
open_timeout[R]
timeout[R]
url[R]
Public Class Methods
new(method, url, headers: {}, body: nil, open_timeout: nil, timeout: nil)
click to toggle source
# File lib/restful_resource/request.rb, line 5 def initialize(method, url, headers: {}, body: nil, open_timeout: nil, timeout: nil) @method = method @url = url @headers = headers @body = body @open_timeout = open_timeout @timeout = timeout end
Public Instance Methods
headers()
click to toggle source
# File lib/restful_resource/request.rb, line 14 def headers default_headers.merge(format_headers) end
Private Instance Methods
default_headers()
click to toggle source
# File lib/restful_resource/request.rb, line 31 def default_headers { 'Accept' => 'application/json' } end
format_headers()
click to toggle source
Formats all keys in Word-Word format
# File lib/restful_resource/request.rb, line 21 def format_headers @headers.stringify_keys.each_with_object({}) do |key_with_value, headers| headers[format_key(key_with_value.first)] = key_with_value.last end end
format_key(key)
click to toggle source
# File lib/restful_resource/request.rb, line 27 def format_key(key) key.humanize.split(' ').map(&:humanize).join('-') end