Method: PDK::Config#get

Defined in:
lib/pdk/config.rb

#get(root, *keys) ⇒ PDK::Config::Namespace, ...

Returns a configuration setting by name. This name can either be a String, Array or parameters e.g. These are equivalent

  • PDK.config.get(‘user.a.b.c’)

  • PDK.config.get([‘user’, ‘a’, ‘b’, ‘c’])

  • PDK.config.get(‘user’, ‘a’, ‘b’, ‘c’)

Parameters:

  • root (Array[String], String)

    The root setting name or the entire setting name as a single string

  • keys (String)

    The child names of the setting

Returns:

  • (PDK::Config::Namespace, Object, nil)

    The value of the configuration setting. Returns nil if it does no exist



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/pdk/config.rb', line 98

def get(root, *keys)
  return nil if root.nil? || root.empty?

  if keys.empty?
    case root
    when Array
      name = root
    when String
      name = split_key_string(root)
    else
      return nil
    end
  else
    name = [root].concat(keys)
  end

  get_within_scopes(name[1..], [name[0]])
end