module ProcessSettings

Constants

OnChangeDeprecation
VERSION

Public Class Methods

[](*path, dynamic_context: {}, required: true) click to toggle source

This is the main entry point for looking up settings in the process.

@example

ProcessSettings['path', 'to', 'setting']

will return 42 in this example settings YAML: code

path:
  to:
    setting:
      42

code

@param [Array(String)] path The path of one or more strings.

@param [Hash] dynamic_context Optional dynamic context hash. It will be merged with the static context.

@param [boolean] required If true (default) will raise `SettingsPathNotFound` if not found; otherwise returns `nil` if not found.

@return setting value

# File lib/process_settings.rb, line 56
def [](*path, dynamic_context: {}, required: true)
  instance[*path, dynamic_context: dynamic_context, required: required]
end
instance() click to toggle source

Getter method for retrieving the current monitor instance being used by ProcessSettings

@return [ProcessSettings::AbstractMonitor]

# File lib/process_settings.rb, line 31
def instance
  Monitor.instance
end
instance=(monitor) click to toggle source

Setter method for assigning the monitor instance for ProcessSettings to use

@example

ProcessSettings.instance = ProcessSettings::FileMonitor.new(...)

@param [ProcessSettings::AbstractMonitor] monitor The monitor to assign for use by ProcessSettings

# File lib/process_settings.rb, line 20
def instance=(monitor)
  if monitor && !monitor.is_a?(ProcessSettings::AbstractMonitor)
    raise ArgumentError, "Invalid monitor of type #{monitor.class.name} provided. Must be of type ProcessSettings::AbstractMonitor"
  end

  Monitor.instance = monitor
end
plain_hash(json_doc) click to toggle source
# File lib/process_settings/util.rb, line 5
def plain_hash(json_doc)
  case json_doc
  when Hash
    result = {}
    json_doc.each { |key, value| result[key] = plain_hash(value) }
    result
  when Array
    json_doc.map { |value| plain_hash(value) }
  else
    if json_doc.respond_to?(:json_doc)
      plain_hash(json_doc.json_doc)
    else
      json_doc
    end
  end
end