Class: ConfigurationManager

mmir. ConfigurationManager

new mmir.ConfigurationManager()

A class for managing the configuration.
It's purpose is to load the configuration and settings automatically. This "class" is structured as a singleton - so that only one instance is in use.

Requires

  • module:mmir.require

Methods

get(propertyName, defaultValue, useSafeAccess){any}

Returns the value of a property.
Name Type Description
propertyName String The name of the property. NOTE: If the property does not exists at the root-level, dot-separated names will be resolved into object-structures, e.g. some.property will be resolved so that the value at: some: {property: <value>} will be returned
defaultValue any optional OPTIONAL a default value that will be returned, in case there is no property propertyName.
useSafeAccess Boolean optional OPTIONAL if true, resolution of dot-separated paths will be done "safely", i.e. if a path-element does not exists, no error will be thrown, but instead the function will return the defaultValue (which will be undefined if the argument is not given).
DEFAULT: true
NOTE: if this argument is used, param defaultValue must also be given!
Returns:
value of the property
Uses get. If the propertyName does not exists, returns undefined, otherwise values will be converted into Boolean values. Special case for Strings: the String "false" will be converted to Boolean value false.
Name Type Description
defaultValue any optional OPTIONAL if a default value is specified and there exists no property propertyName, the specified default value will be returned. NOTE: if this argument is used, useSafeAccess must also be given! NOTE: the default value will also be converted to a Boolean value, if necessary.
See:
  • #get
Uses get. If the property does not exists, returns undefined, otherwise values will be converted into String values. If the value has not the type "string", it will be converted by JSON.stringify.
Name Type Description
defaultValue any optional OPTIONAL if a default value is specified and there exists no property propertyName, the specified default value will be returned. NOTE: if this argument is used, useSafeAccess must also be given! NOTE: the default value will also be converted to a String value, if necessary.
See:
  • #get
Sets a property to a given value.
Name Type Description
propertyName String | Array.<String> The name of the property. If propertyName is an Array, it will be treated as if its entries were path-elements analogous to a dot-separated String propertyName. NOTE: dot-separated names will be resolved into object-structures, e.g. some.property will be resolved so that the value will set to: some: {property: <value>}
value any The value of the property
Throws:
if the propertyName is dot-separated AND one of its path-elements (except for the last) already exists AND its type is not 'object'
Type
Error