Module: Fabric::Configuration

Included in:
Fabric
Defined in:
lib/fabric/configuration.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
30
VALID_OPTIONS_KEYS =
%i[
  orderers
  peers
  event_hubs
  identity
  timeout
  logger
  logger_filters
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



17
18
19
# File 'lib/fabric/configuration.rb', line 17

def self.extended(base)
  base.reset
end

Instance Method Details

#assign(config) ⇒ Object



40
41
42
# File 'lib/fabric/configuration.rb', line 40

def assign(config)
  VALID_OPTIONS_KEYS.each { |key| send("#{key}=", config[key]) if config.key?(key) }
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



21
22
23
# File 'lib/fabric/configuration.rb', line 21

def configure
  yield self
end

#optionsObject



25
26
27
28
29
# File 'lib/fabric/configuration.rb', line 25

def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#resetObject



31
32
33
34
35
36
37
38
# File 'lib/fabric/configuration.rb', line 31

def reset
  VALID_OPTIONS_KEYS.each { |key| send("#{key}=", nil) }

  self.orderers = []
  self.peers = []
  self.event_hubs = []
  self.timeout = DEFAULT_TIMEOUT
end