Class: Briefbag::Diplomat
- Inherits:
-
Object
- Object
- Briefbag::Diplomat
- Defined in:
- lib/briefbag/diplomat.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#consul_folder ⇒ Object
readonly
Returns the value of attribute consul_folder.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #call ⇒ Object
- #configuration ⇒ Object
-
#initialize(config) ⇒ Diplomat
constructor
A new instance of Diplomat.
Constructor Details
#initialize(config) ⇒ Diplomat
Returns a new instance of Diplomat.
11 12 13 14 15 16 |
# File 'lib/briefbag/diplomat.rb', line 11 def initialize(config) @config = config @host = config[:consul_host] @port = config[:consul_port].nil? ? 443 : config[:consul_port] @consul_folder = "#{config[:environment]}/#{config[:consul_folder]}" end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/briefbag/diplomat.rb', line 9 def config @config end |
#consul_folder ⇒ Object (readonly)
Returns the value of attribute consul_folder.
9 10 11 |
# File 'lib/briefbag/diplomat.rb', line 9 def consul_folder @consul_folder end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/briefbag/diplomat.rb', line 9 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/briefbag/diplomat.rb', line 9 def port @port end |
Instance Method Details
#call ⇒ Object
18 19 20 21 |
# File 'lib/briefbag/diplomat.rb', line 18 def call configuration data_from_consul end |
#configuration ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/briefbag/diplomat.rb', line 23 def configuration ::Diplomat.configure do |conf| # Set up a custom Consul URL conf.url = url_build break if config[:consul_token].nil? conf. = { ssl: { version: :TLSv1_2 }, # rubocop:disable Naming/VariableNumber headers: { 'X-Consul-Token' => config[:consul_token] } } end end |