Module: Consulkit::Configurable

Included in:
Consulkit, Client
Defined in:
lib/consulkit/configurable.rb

Overview

Configuration options for the Consulkit singleton and individual Client instances.

Constant Summary collapse

CONFIGURABLE_KEYS =
%i[
  connection_options
  http_addr
  http_token
  middleware
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connection_optionsObject

Hash

Faraday connection options



14
15
16
# File 'lib/consulkit/configurable.rb', line 14

def connection_options
  @connection_options
end

#http_addrObject

String

the HTTP(s) address to use to connect to Consul



8
9
10
# File 'lib/consulkit/configurable.rb', line 8

def http_addr
  @http_addr
end

#http_token=(value) ⇒ Object (writeonly)

String

the ACL token used for authentication



11
12
13
# File 'lib/consulkit/configurable.rb', line 11

def http_token=(value)
  @http_token = value
end

#middlewareObject

Faraday::RackBuilder

middleware for Faraday



17
18
19
# File 'lib/consulkit/configurable.rb', line 17

def middleware
  @middleware
end

Instance Method Details

#optionsObject



34
35
36
# File 'lib/consulkit/configurable.rb', line 34

def options
  CONFIGURABLE_KEYS.to_h { |key| [key, instance_variable_get("@#{key}")] }
end

#setup!Object



26
27
28
29
30
31
32
# File 'lib/consulkit/configurable.rb', line 26

def setup!
  CONFIGURABLE_KEYS.each do |key|
    instance_variable_set(:"@#{key}", Consulkit::Defaults.send(key))
  end

  self
end