Class: Blanket::Wrapper
- Inherits:
-
Object
- Object
- Blanket::Wrapper
- Defined in:
- lib/blanket/wrapper.rb
Instance Attribute Summary collapse
-
#extension ⇒ Object
Attribute accessor for file extension that should be appended to all requests.
-
#headers ⇒ Object
Attribute accessor for HTTP Headers that should be applied to all requests.
-
#params ⇒ Object
Attribute accessor for params that should be applied to all requests.
Instance Method Summary collapse
-
#delete ⇒ Blanket::Response, Array
Performs a delete request on the wrapped URL.
-
#get ⇒ Blanket::Response, Array
Performs a get request on the wrapped URL.
-
#initialize(base_uri, options = {}) ⇒ Blanket
constructor
Wraps the base URL for an API.
-
#patch ⇒ Blanket::Response, Array
Performs a patch request on the wrapped URL.
-
#post ⇒ Blanket::Response, Array
Performs a post request on the wrapped URL.
-
#put ⇒ Blanket::Response, Array
Performs a put request on the wrapped URL.
Constructor Details
#initialize(base_uri, options = {}) ⇒ Blanket
Wraps the base URL for an API
42 43 44 45 46 47 48 |
# File 'lib/blanket/wrapper.rb', line 42 def initialize(base_uri, ={}) @base_uri = base_uri @uri_parts = [] @headers = [:headers] || {} @params = [:params] || {} @extension = [:extension] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#extension ⇒ Object
Attribute accessor for file extension that should be appended to all requests
30 31 32 |
# File 'lib/blanket/wrapper.rb', line 30 def extension @extension end |
#headers ⇒ Object
Attribute accessor for HTTP Headers that should be applied to all requests
22 23 24 |
# File 'lib/blanket/wrapper.rb', line 22 def headers @headers end |
#params ⇒ Object
Attribute accessor for params that should be applied to all requests
26 27 28 |
# File 'lib/blanket/wrapper.rb', line 26 def params @params end |
Instance Method Details
#delete ⇒ Blanket::Response, Array
Performs a delete request on the wrapped URL
36 |
# File 'lib/blanket/wrapper.rb', line 36 add_action :delete |
#get ⇒ Blanket::Response, Array
Performs a get request on the wrapped URL
32 |
# File 'lib/blanket/wrapper.rb', line 32 add_action :get |
#patch ⇒ Blanket::Response, Array
Performs a patch request on the wrapped URL
35 |
# File 'lib/blanket/wrapper.rb', line 35 add_action :patch |
#post ⇒ Blanket::Response, Array
Performs a post request on the wrapped URL
33 |
# File 'lib/blanket/wrapper.rb', line 33 add_action :post |
#put ⇒ Blanket::Response, Array
Performs a put request on the wrapped URL
34 |
# File 'lib/blanket/wrapper.rb', line 34 add_action :put |