Class: ApiClient::Configuration
- Inherits:
-
Object
- Object
- ApiClient::Configuration
- Defined in:
- lib/api-client/configuration.rb
Overview
ApiClient::Configuration provides a way to configure ApiClient globally.
Instance Attribute Summary collapse
-
#header ⇒ Object
Returns the value of attribute header.
-
#hydra ⇒ Object
Returns the value of attribute hydra.
-
#mock ⇒ Object
Returns the value of attribute mock.
Instance Method Summary collapse
-
#basic_auth(account, password) ⇒ Object
Set a basic authentication for all requisitions.
-
#path ⇒ String
Return the api url.
-
#path=(path) ⇒ Object
Set the api url.
-
#paths=(paths = {}) ⇒ Object
Set several api urls.
Instance Attribute Details
#header ⇒ Object
Returns the value of attribute header.
5 6 7 |
# File 'lib/api-client/configuration.rb', line 5 def header @header end |
#hydra ⇒ Object
Returns the value of attribute hydra.
4 5 6 |
# File 'lib/api-client/configuration.rb', line 4 def hydra @hydra end |
#mock ⇒ Object
Returns the value of attribute mock.
4 5 6 |
# File 'lib/api-client/configuration.rb', line 4 def mock @mock end |
Instance Method Details
#basic_auth(account, password) ⇒ Object
Set a basic authentication for all requisitions.
50 51 52 |
# File 'lib/api-client/configuration.rb', line 50 def basic_auth(account, password) @header.merge!({ 'Authorization' => "Basic #{["#{account}:#{password}"].pack('m').delete("\r\n")}" }) end |
#path ⇒ String
Return the api url.
10 11 12 13 14 15 |
# File 'lib/api-client/configuration.rb', line 10 def path @paths.each do |name, path| raise Exceptions::BadlyConfigured.new(name) unless path.size > 1 end @paths end |
#path=(path) ⇒ Object
Set the api url.
20 21 22 23 |
# File 'lib/api-client/configuration.rb', line 20 def path=(path) path = "#{path}/" unless path[path.size - 1, 1] == '/' @paths = { :default => path } end |
#paths=(paths = {}) ⇒ Object
Set several api urls.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/api-client/configuration.rb', line 28 def paths=(paths = {}) @paths = {} paths.each do |name, path| if path[path.size - 1, 1] == '/' @paths[name] = path else @paths[name] = "#{path}/" end end end |