class Instapaper::HTTP::Request
Constants
- BASE_URL
Attributes
client[RW]
headers[RW]
options[RW]
path[RW]
request_method[RW]
uri[RW]
Public Class Methods
new(client, request_method, path, options = {})
click to toggle source
@param client [Instapaper::Client] @param request_method
[String, Symbol] @param path [String] @param options [Hash] @return [Instapaper::HTTP::Request]
# File lib/instapaper/http/request.rb, line 17 def initialize(client, request_method, path, options = {}) @client = client @request_method = request_method @uri = Addressable::URI.parse(path.start_with?('http') ? path : BASE_URL + path) @path = uri.path @options = options end
Public Instance Methods
perform()
click to toggle source
@return [Array, Hash]
# File lib/instapaper/http/request.rb, line 26 def perform raw = @options.delete(:raw) response = Instapaper::HTTP::Response.new(perform_request, path, raw) response.valid? && response.body end
Private Instance Methods
perform_request()
click to toggle source
# File lib/instapaper/http/request.rb, line 34 def perform_request @headers = Instapaper::HTTP::Headers.new(@client, @request_method, @uri, @options).request_headers options_key = @request_method == :get ? :params : :form ::HTTP.headers(@headers).public_send(@request_method, @uri.to_s, options_key => @options) end