class ProcessSettings::Testing::MonitorStub

This class implements the Monitor#targeted_value interface but is stubbed to use a simple hash in tests

Public Class Methods

new(*_args) click to toggle source
Calls superclass method
# File lib/process_settings/testing/monitor_stub.rb, line 15
def new(*_args)
  ActiveSupport::Deprecation.warn("ProcessSettings::Testing::MonitorStub is deprecated and will be removed in future versions. Use ProcessSettings::Testing::Monitor instead.", caller)
  super
end
new(settings_hash) click to toggle source
# File lib/process_settings/testing/monitor_stub.rb, line 21
def initialize(settings_hash)
  @settings_hash = HashWithHashPath[settings_hash]
end

Public Instance Methods

[](*path, dynamic_context: {}, required: true) click to toggle source
# File lib/process_settings/testing/monitor_stub.rb, line 25
def [](*path, dynamic_context: {}, required: true)
  targeted_value(*path, dynamic_context: dynamic_context, required: required)
end
targeted_value(*path, dynamic_context:, required: true) click to toggle source
# File lib/process_settings/testing/monitor_stub.rb, line 29
def targeted_value(*path, dynamic_context:, required: true)
  result = @settings_hash.mine(*path, not_found_value: :not_found)

  if result == :not_found
    if required
      raise SettingsPathNotFound, "no settings found for path #{path.inspect}"
    else
      nil
    end
  else
    result
  end
end