class Freno::Client::Request
Attributes
args[R]
faraday[R]
options[R]
raise_on_timeout[R]
Public Class Methods
new(**kwargs)
click to toggle source
# File lib/freno/client/request.rb, line 18 def initialize(**kwargs) @args = kwargs @faraday = kwargs.delete(:faraday) || nil @options = kwargs.delete(:options) || Hash.new @raise_on_timeout = options.fetch(:raise_on_timeout, true) @verb = options.fetch(:verb, :head) end
perform(**kwargs)
click to toggle source
# File lib/freno/client/request.rb, line 14 def self.perform(**kwargs) new(**kwargs).perform end
Public Instance Methods
perform()
click to toggle source
# File lib/freno/client/request.rb, line 27 def perform response = request(verb, path, params) process_response(response) rescue Faraday::TimeoutError => ex raise Freno::Error.new(ex) if raise_on_timeout Result.from_meaning(:request_timeout) rescue => ex raise Freno::Error.new(ex) end
Protected Instance Methods
params()
click to toggle source
# File lib/freno/client/request.rb, line 55 def params @params ||= {} end
path()
click to toggle source
# File lib/freno/client/request.rb, line 43 def path @path || begin raise NotImplementedError("must be overriden in specific requests, or memoized in @path") end end
process_response(response)
click to toggle source
# File lib/freno/client/request.rb, line 59 def process_response(response) Result.from_faraday_response(response) end
request(verb, path, params)
click to toggle source
# File lib/freno/client/request.rb, line 39 def request(verb, path, params) faraday.send(verb, path, params) end
verb()
click to toggle source
# File lib/freno/client/request.rb, line 49 def verb @verb || begin raise NotImplementedError("must be overriden in specific requests, or memoized in @verb") end end