Module: Gruf::Balancer::Configuration

Included in:
Gruf::Balancer
Defined in:
lib/gruf/balancer/configuration.rb

Overview

Represents configuration settings for the system

Constant Summary collapse

VALID_CONFIG_KEYS =
{}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Whenever this is extended into a class, setup the defaults



31
32
33
# File 'lib/gruf/balancer/configuration.rb', line 31

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Gruf::Balancer::Configuration

Yield self for ruby-style initialization

Yields:

  • (_self)

Yield Parameters:

Returns:



41
42
43
# File 'lib/gruf/balancer/configuration.rb', line 41

def configure
  yield self
end

#optionsHash

Return the current configuration options as a Hash

Returns:

  • (Hash)

    The configuration represented as a Hash



50
51
52
53
54
55
56
# File 'lib/gruf/balancer/configuration.rb', line 50

def options
  opts = {}
  VALID_CONFIG_KEYS.each_key do |k|
    opts.merge!(k => send(k))
  end
  opts
end

#resetHash

Set the default configuration onto the extended class

Returns:

  • (Hash)

    options The reset options hash



63
64
65
66
67
68
# File 'lib/gruf/balancer/configuration.rb', line 63

def reset
  VALID_CONFIG_KEYS.each do |k, v|
    send("#{k}=", v)
  end
  options
end