Class: Gorilla::VanillaClient
- Inherits:
-
Object
- Object
- Gorilla::VanillaClient
- Defined in:
- lib/gorilla/vanilla_client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #config ⇒ Object
- #delete(path, params = {}) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(opts = {}, &block) ⇒ VanillaClient
constructor
A new instance of VanillaClient.
- #post(path, params = {}) ⇒ Object
- #put(path, params = {}) ⇒ Object
Constructor Details
#initialize(opts = {}, &block) ⇒ VanillaClient
Returns a new instance of VanillaClient.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gorilla/vanilla_client.rb', line 6 def initialize(opts={}, &block) = config.api.to_h.merge(opts) @connection = Faraday.new([:url]) do |conn| conn.request :multipart conn.request :user_agent, config.user_agent conn.request :url_encoded yield(conn, ) if block_given? conn.response :json, content_type: /\bjson$/ conn.adapter *config.client_adapter end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/gorilla/vanilla_client.rb', line 4 def connection @connection end |
Instance Method Details
#config ⇒ Object
35 36 37 |
# File 'lib/gorilla/vanilla_client.rb', line 35 def config Gorilla.configuration end |
#delete(path, params = {}) ⇒ Object
31 32 33 |
# File 'lib/gorilla/vanilla_client.rb', line 31 def delete(path, params={}) request(:delete, path, params) end |
#get(path, params = {}) ⇒ Object
19 20 21 |
# File 'lib/gorilla/vanilla_client.rb', line 19 def get(path, params={}) request(:get, path, params) end |
#post(path, params = {}) ⇒ Object
23 24 25 |
# File 'lib/gorilla/vanilla_client.rb', line 23 def post(path, params={}) request(:post, path, params) end |
#put(path, params = {}) ⇒ Object
27 28 29 |
# File 'lib/gorilla/vanilla_client.rb', line 27 def put(path, params={}) request(:put, path, params) end |