module CassetteRack::Request
Attributes
request_options[R]
Public Instance Methods
delete(path, headers={})
click to toggle source
# File lib/cassette-rack/request.rb, line 24 def delete(path, headers={}) request(:delete, path, {}, headers) end
get(path, params={}, headers={})
click to toggle source
# File lib/cassette-rack/request.rb, line 8 def get(path, params={}, headers={}) request(:get, path, params, headers) end
parse_content(body, req)
click to toggle source
# File lib/cassette-rack/request.rb, line 53 def parse_content(body, req) if req.headers['content-type'] == 'application/json' and body.is_a?(Hash) body.to_json else body end end
patch(path, body={}, headers={})
click to toggle source
# File lib/cassette-rack/request.rb, line 16 def patch(path, body={}, headers={}) request(:patch, path, {}, headers, body) end
post(path, body={}, headers={})
click to toggle source
# File lib/cassette-rack/request.rb, line 12 def post(path, body={}, headers={}) request(:post, path, {}, headers, body) end
put(path, body={}, headers={})
click to toggle source
# File lib/cassette-rack/request.rb, line 20 def put(path, body={}, headers={}) request(:put, path, {}, headers, body) end
request(method, path, params={}, headers={}, body={}, options={})
click to toggle source
# File lib/cassette-rack/request.rb, line 28 def request(method, path, params={}, headers={}, body={}, options={}) if request_options options = request_options else options = { url: CassetteRack.config.url, headers: headers } end conn = Faraday.new(options) res = conn.send(method) do |req| case method when :get, :delete req.url path, params when :post, :patch, :put req.path = path req.body = parse_content(body, req) end end @response = CassetteRack::Response.new(res) end
response()
click to toggle source
# File lib/cassette-rack/request.rb, line 49 def response @response end