Module: ProcessSettings
- Defined in:
- lib/process_settings.rb,
lib/process_settings.rb,
lib/process_settings/util.rb,
lib/process_settings/target.rb,
lib/process_settings/monitor.rb,
lib/process_settings/version.rb,
lib/process_settings/settings.rb,
lib/process_settings/hash_path.rb,
lib/process_settings/file_monitor.rb,
lib/process_settings/testing/helpers.rb,
lib/process_settings/testing/monitor.rb,
lib/process_settings/abstract_monitor.rb,
lib/process_settings/helpers/watchdog.rb,
lib/process_settings/targeted_settings.rb,
lib/process_settings/hash_with_hash_path.rb,
lib/process_settings/target_and_settings.rb,
lib/process_settings/testing/monitor_stub.rb,
lib/process_settings/replace_versioned_file.rb
Defined Under Namespace
Modules: HashPath, ReplaceVersionedFile, Testing Classes: AbstractMonitor, FileMonitor, HashWithHashPath, Monitor, Settings, SettingsPathNotFound, Target, TargetAndSettings, TargetedSettings, Watchdog
Constant Summary collapse
- VERSION =
'0.20.0'
- OnChangeDeprecation =
ActiveSupport::Deprecation.new('1.0', 'ProcessSettings::Monitor')
Class Method Summary collapse
-
.[](*path, dynamic_context: {}, required: true) ⇒ Object
This is the main entry point for looking up settings in the process.
-
.instance ⇒ ProcessSettings::AbstractMonitor
Getter method for retrieving the current monitor instance being used by ProcessSettings.
-
.instance=(monitor) ⇒ Object
Setter method for assigning the monitor instance for ProcessSettings to use.
- .plain_hash(json_doc) ⇒ Object
Class Method Details
.[](*path, dynamic_context: {}, required: true) ⇒ Object
This is the main entry point for looking up settings in the process.
ProcessSettings[‘path’, ‘to’, ‘setting’]
will return 42 in this example settings YAML: code
path:
to:
setting:
42
code
57 58 59 |
# File 'lib/process_settings.rb', line 57 def [](*path, dynamic_context: {}, required: true) instance[*path, dynamic_context: dynamic_context, required: required] end |
.instance ⇒ ProcessSettings::AbstractMonitor
Getter method for retrieving the current monitor instance being used by ProcessSettings
32 33 34 |
# File 'lib/process_settings.rb', line 32 def instance Monitor.instance end |
.instance=(monitor) ⇒ Object
Setter method for assigning the monitor instance for ProcessSettings to use
ProcessSettings.instance = ProcessSettings::FileMonitor.new(…)
21 22 23 24 25 26 27 |
# File 'lib/process_settings.rb', line 21 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) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 |