Method: Config#has_path

Defined in:
lib/hocon/config.rb

#has_path(path) ⇒ Object

Checks whether a value is present and non-null at the given path. This differs in two ways from Map.containsKey() as implemented by ConfigObject: it looks for a path expression, not a key; and it returns false for null values, while containsKey() returns true indicating that the object contains a null value for the key.

<p> If a path exists according to #hasPath(String), then #getValue(String) will never throw an exception. However, the typed getters, such as #getInt(String), will still throw if the value is not convertible to the requested type.

<p> Note that path expressions have a syntax and sometimes require quoting (see ConfigUtil#joinPath and ConfigUtil#splitPath).

Parameters:

  • path

    the path expression

Returns:

  • true if a non-null value is present at the path

Raises:



387
388
389
# File 'lib/hocon/config.rb', line 387

def has_path(path)
  raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Config` must implement `has_path` (#{self.class})"
end