Class: GarageClient::Configuration
- Inherits:
-
Object
- Object
- GarageClient::Configuration
- Defined in:
- lib/garage_client/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ adapter: :net_http, cacher: nil, path_prefix: '/v1', verbose: false, }
Class Method Summary collapse
Instance Method Summary collapse
- #default_user_agent ⇒ Object
- #endpoint ⇒ Object
- #endpoint=(value) ⇒ Object
- #headers ⇒ Object (also: #default_headers)
- #headers=(value) ⇒ Object (also: #default_headers=)
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #name ⇒ Object
- #name=(value) ⇒ Object
- #options ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 |
# File 'lib/garage_client/configuration.rb', line 14 def initialize( = {}) @options = end |
Class Method Details
.keys ⇒ Object
10 11 12 |
# File 'lib/garage_client/configuration.rb', line 10 def self.keys DEFAULTS.keys + [:endpoint, :headers] end |
Instance Method Details
#default_user_agent ⇒ Object
52 53 54 |
# File 'lib/garage_client/configuration.rb', line 52 def default_user_agent "garage_client #{GarageClient::VERSION} #{name}" end |
#endpoint ⇒ Object
36 37 38 |
# File 'lib/garage_client/configuration.rb', line 36 def endpoint [:endpoint] or raise 'Configuration error: missing endpoint' end |
#endpoint=(value) ⇒ Object
40 41 42 |
# File 'lib/garage_client/configuration.rb', line 40 def endpoint=(value) [:endpoint] = value end |
#headers ⇒ Object Also known as: default_headers
56 57 58 59 60 61 62 63 |
# File 'lib/garage_client/configuration.rb', line 56 def headers .fetch(:headers) do { 'Accept' => 'application/json', 'User-Agent' => default_user_agent, } end end |
#headers=(value) ⇒ Object Also known as: default_headers=
65 66 67 |
# File 'lib/garage_client/configuration.rb', line 65 def headers=(value) [:headers] = value end |
#name ⇒ Object
44 45 46 |
# File 'lib/garage_client/configuration.rb', line 44 def name [:name] or raise 'Configuration error: missing name' end |
#name=(value) ⇒ Object
48 49 50 |
# File 'lib/garage_client/configuration.rb', line 48 def name=(value) [:name] = value end |
#options ⇒ Object
18 19 20 |
# File 'lib/garage_client/configuration.rb', line 18 def @options ||= {} end |
#reset ⇒ Object
22 23 24 |
# File 'lib/garage_client/configuration.rb', line 22 def reset @options = nil end |