Module: Lavin::HttpClient
- Defined in:
- lib/lavin/http_client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#index ⇒ Object
writeonly
Sets the attribute index.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #delete(url, headers: {}) ⇒ Object
- #get(url, headers: {}) ⇒ Object
- #head(url, headers: {}) ⇒ Object
- #initialize(**kwargs) ⇒ Object
- #patch(url, headers: {}, body: nil) ⇒ Object
- #post(url, headers: {}, body: nil) ⇒ Object
- #put(url, headers: {}, body: nil) ⇒ Object
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/lavin/http_client.rb', line 7 def client @client end |
#index=(value) ⇒ Object (writeonly)
Sets the attribute index
8 9 10 |
# File 'lib/lavin/http_client.rb', line 8 def index=(value) @index = value end |
Instance Method Details
#cleanup ⇒ Object
15 16 17 |
# File 'lib/lavin/http_client.rb', line 15 def cleanup client&.close end |
#delete(url, headers: {}) ⇒ Object
39 40 41 |
# File 'lib/lavin/http_client.rb', line 39 def delete(url, headers: {}) request(:delete, url:, headers:) end |
#get(url, headers: {}) ⇒ Object
19 20 21 |
# File 'lib/lavin/http_client.rb', line 19 def get(url, headers: {}) request(:get, url:, headers:) end |
#head(url, headers: {}) ⇒ Object
23 24 25 |
# File 'lib/lavin/http_client.rb', line 23 def head(url, headers: {}) request(:head, url:, headers:) end |
#initialize(**kwargs) ⇒ Object
10 11 12 13 |
# File 'lib/lavin/http_client.rb', line 10 def initialize(**kwargs) super(**kwargs) @client = kwargs.fetch(:client) { Client.new(config[:base_url]) } end |
#patch(url, headers: {}, body: nil) ⇒ Object
35 36 37 |
# File 'lib/lavin/http_client.rb', line 35 def patch(url, headers: {}, body: nil) request(:patch, url:, headers:, body:) end |
#post(url, headers: {}, body: nil) ⇒ Object
27 28 29 |
# File 'lib/lavin/http_client.rb', line 27 def post(url, headers: {}, body: nil) request(:post, url:, headers:, body:) end |
#put(url, headers: {}, body: nil) ⇒ Object
31 32 33 |
# File 'lib/lavin/http_client.rb', line 31 def put(url, headers: {}, body: nil) request(:put, url:, headers:, body:) end |