Class: ActiveClient::Base
- Inherits:
-
Object
- Object
- ActiveClient::Base
- Defined in:
- lib/active_client/base.rb
Defined Under Namespace
Classes: Response
Class Method Summary collapse
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path, skip_parsing: false, **query) ⇒ Object
- #multipart_post(path, body, skip_parsing: false) ⇒ Object
- #post(path, **body) ⇒ Object
Class Method Details
.http ⇒ Object
13 14 15 |
# File 'lib/active_client/base.rb', line 13 def self.http @http end |
.with_persistent_connection ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/active_client/base.rb', line 4 def self.with_persistent_connection(&) @http = Net::HTTP::Persistent.new name: "gemini" yield @http.shutdown @http = nil end |
Instance Method Details
#delete(path) ⇒ Object
25 26 27 |
# File 'lib/active_client/base.rb', line 25 def delete(path) make_request(Net::HTTP::Delete, path) end |
#get(path, skip_parsing: false, **query) ⇒ Object
17 18 19 |
# File 'lib/active_client/base.rb', line 17 def get(path, skip_parsing: false, **query) make_request(Net::HTTP::Get, path, skip_parsing:, query:) end |
#multipart_post(path, body, skip_parsing: false) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/active_client/base.rb', line 29 def multipart_post(path, body, skip_parsing: false) instrument(klass: Net::HTTP::Post, path:, query: nil, body: nil) do |http, request| request.set_form(body, "multipart/form-data") response = http.request(request) Response.new(parse_response(response.body, skip_parsing), response.is_a?(Net::HTTPSuccess)) end end |
#post(path, **body) ⇒ Object
21 22 23 |
# File 'lib/active_client/base.rb', line 21 def post(path, **body) make_request(Net::HTTP::Post, path, body:) end |