Class: Diplomat::Configuration
- Inherits:
-
Object
- Object
- Diplomat::Configuration
- Defined in:
- lib/diplomat/configuration.rb
Overview
Methods for configuring Diplomat
Instance Attribute Summary collapse
-
#acl_token ⇒ Object
Returns the value of attribute acl_token.
-
#middleware ⇒ Object
Returns the value of attribute middleware.
-
#options ⇒ Object
Returns the value of attribute options.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
-
.parse_consul_addr ⇒ Object
Get the most appropriate consul agent value from env Parse the environment variable ‘CONSUL_HTTP_ADDR` and prefixes it with http:// if needed Return default localhost:8500 if not found.
Instance Method Summary collapse
-
#initialize(url = Configuration.parse_consul_addr, acl_token = ENV['CONSUL_HTTP_TOKEN'], options = {}) ⇒ Configuration
constructor
Override defaults for configuration.
Constructor Details
#initialize(url = Configuration.parse_consul_addr, acl_token = ENV['CONSUL_HTTP_TOKEN'], options = {}) ⇒ Configuration
Override defaults for configuration
22 23 24 25 26 27 |
# File 'lib/diplomat/configuration.rb', line 22 def initialize(url = Configuration.parse_consul_addr, acl_token = ENV['CONSUL_HTTP_TOKEN'], = {}) @middleware = [] @url = url @acl_token = acl_token @options = end |
Instance Attribute Details
#acl_token ⇒ Object
Returns the value of attribute acl_token.
7 8 9 |
# File 'lib/diplomat/configuration.rb', line 7 def acl_token @acl_token end |
#middleware ⇒ Object
Returns the value of attribute middleware.
6 7 8 |
# File 'lib/diplomat/configuration.rb', line 6 def middleware @middleware end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/diplomat/configuration.rb', line 7 def @options end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/diplomat/configuration.rb', line 7 def url @url end |
Class Method Details
.parse_consul_addr ⇒ Object
Get the most appropriate consul agent value from env Parse the environment variable ‘CONSUL_HTTP_ADDR` and prefixes it with http:// if needed Return default localhost:8500 if not found
12 13 14 15 16 |
# File 'lib/diplomat/configuration.rb', line 12 def self.parse_consul_addr ret = ENV['CONSUL_HTTP_ADDR'] || 'http://localhost:8500' ret = "http://#{ret}" unless ret.start_with?('http://', 'https://') ret end |