Module: GClouder::ConfigSection

Includes:
Logging
Defined in:
lib/gclouder/config_section.rb

Class Method Summary collapse

Methods included from Logging

#add, #bad, #change, #debug, #error, #fatal, #good, #info, log, loggers, #remove, report, #resource_state, setup, #warn, #warning

Class Method Details

.find(path, data, silent: false) ⇒ Object

Raises:

  • (StandardError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gclouder/config_section.rb', line 11

def self.find(path, data, silent: false)
  raise StandardError, "find: path argument must be an array: #{path.inspect}" unless path.is_a?(Array)
  raise StandardError, "find: data argument must be an hash: #{path.inspect}" unless data.is_a?(Hash)

  section = data.dig(*path)

  if section
    return silent ? true : section
  end

  return false if silent

  fatal "can't find key in data: #{path}"
end

.included(klass) ⇒ Object



7
8
9
# File 'lib/gclouder/config_section.rb', line 7

def self.included(klass)
  klass.extend ConfigSection
end