class Resty::Request
Attributes
global_options[R]
params[R]
Public Class Methods
data_required?(method)
click to toggle source
# File lib/resty/request.rb, line 18 def self.data_required?(method) (method =~ %r{put|post|patch}) == 0 end
new(global_options, params)
click to toggle source
# File lib/resty/request.rb, line 8 def initialize(global_options, params) @global_options = global_options @params = params end
Public Instance Methods
send_request(options = {}) { |params| ... }
click to toggle source
# File lib/resty/request.rb, line 13 def send_request(options = {}) request_options[:headers].merge!(options[:headers]) if options[:headers] RestClient::Request.new(request_options).execute { |*params| yield params } end
Private Instance Methods
data()
click to toggle source
# File lib/resty/request.rb, line 47 def data params[:data] end
method()
click to toggle source
# File lib/resty/request.rb, line 39 def method params[:method] end
path()
click to toggle source
# File lib/resty/request.rb, line 43 def path params[:path] end
request_options()
click to toggle source
# File lib/resty/request.rb, line 24 def request_options @request_options ||= {}.tap do |options| options[:method] = method options[:headers] = global_options.headers options[:url] = url options[:user] = global_options.username if global_options.username options[:password] = global_options.password if global_options.password options[:payload] = JSON.dump(data) if Resty::Request.data_required?(method) end end
url()
click to toggle source
# File lib/resty/request.rb, line 35 def url "#{global_options.host}#{path}" end