module Footrest::Request
Public Instance Methods
delete(path, options={})
click to toggle source
# File lib/footrest/request.rb, line 8 def delete(path, options={}) request_with_params_in_url(:delete, path, options) end
fullpath(path)
click to toggle source
# File lib/footrest/request.rb, line 4 def fullpath(path) raise "fullpath should be overridden" end
get(path, options={})
click to toggle source
# File lib/footrest/request.rb, line 12 def get(path, options={}) request_with_params_in_url(:get, path, options) end
patch(path, options={})
click to toggle source
# File lib/footrest/request.rb, line 24 def patch(path, options={}) request_with_params_in_body(:patch, path, options) end
post(path, options={})
click to toggle source
# File lib/footrest/request.rb, line 16 def post(path, options={}) request_with_params_in_body(:post, path, options) end
put(path, options={})
click to toggle source
# File lib/footrest/request.rb, line 20 def put(path, options={}) request_with_params_in_body(:put, path, options) end
request(method, &block)
click to toggle source
Generic request
# File lib/footrest/request.rb, line 42 def request(method, &block) connection.send(method, &block).body end
request_with_params_in_body(method, path, options)
click to toggle source
# File lib/footrest/request.rb, line 34 def request_with_params_in_body(method, path, options) request(method) do |r| r.path = fullpath(path) r.body = options unless options.empty? end end
request_with_params_in_url(method, path, options)
click to toggle source
# File lib/footrest/request.rb, line 28 def request_with_params_in_url(method, path, options) request(method) do |r| r.url(fullpath(path), options) end end