Method: CMDB::Interface#initialize

Defined in:
lib/cmdb/interface.rb

#initialize(settings = {}) ⇒ Interface

Create a new instance of the CMDB interface.

Parameters:

  • settings (Hash) (defaults to: {})

    a customizable set of options

Options Hash (settings):

  • root (String)

    name of subkey to consider as root



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cmdb/interface.rb', line 8

def initialize(settings = {})
  @root = settings[:root] if settings

  namespaces = {}

  load_file_sources(namespaces)
  check_overlap(namespaces)

  @sources = []
  # Load from consul source first if one is available.
  unless ConsulSource.url.nil?
    if ConsulSource.prefixes.nil? || ConsulSource.prefixes.empty?
      @sources << ConsulSource.new('')
    else
      ConsulSource.prefixes.each do |prefix|
        @sources << ConsulSource.new(prefix)
      end
    end
  end
  # Register valid sources with CMDB
  namespaces.each do |_, v|
    @sources << v.first
  end
end