Class: Freno::Client::Request
- Inherits:
-
Object
- Object
- Freno::Client::Request
- Includes:
- Preconditions
- Defined in:
- lib/freno/client/request.rb
Direct Known Subclasses
Freno::Client::Requests::Check, Freno::Client::Requests::CheckRead
Constant Summary
Constants included from Preconditions
Preconditions::PreconditionNotMet
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#faraday ⇒ Object
readonly
Returns the value of attribute faraday.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#raise_on_timeout ⇒ Object
readonly
Returns the value of attribute raise_on_timeout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Methods included from Preconditions
Constructor Details
#initialize(**kwargs) ⇒ Request
Returns a new instance of Request.
18 19 20 21 22 23 24 25 |
# File 'lib/freno/client/request.rb', line 18 def initialize(**kwargs) @args = kwargs @faraday = kwargs.delete(:faraday) || nil @options = kwargs.delete(:options) || {} @raise_on_timeout = .fetch(:raise_on_timeout, true) @verb = .fetch(:verb, :head) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
12 13 14 |
# File 'lib/freno/client/request.rb', line 12 def args @args end |
#faraday ⇒ Object (readonly)
Returns the value of attribute faraday.
12 13 14 |
# File 'lib/freno/client/request.rb', line 12 def faraday @faraday end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/freno/client/request.rb', line 12 def @options end |
#raise_on_timeout ⇒ Object (readonly)
Returns the value of attribute raise_on_timeout.
12 13 14 |
# File 'lib/freno/client/request.rb', line 12 def raise_on_timeout @raise_on_timeout end |
Class Method Details
.perform(**kwargs) ⇒ Object
14 15 16 |
# File 'lib/freno/client/request.rb', line 14 def self.perform(**kwargs) new(**kwargs).perform end |
Instance Method Details
#perform ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/freno/client/request.rb', line 27 def perform response = request(verb, path, params) process_response(response) rescue Faraday::TimeoutError => error raise Freno::Error, error if raise_on_timeout Result.from_meaning(:request_timeout) rescue StandardError => error raise Freno::Error, error end |