Class: PatientHttp::Sidekiq::Configuration::ProfileConfiguration

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/patient_http/sidekiq/configuration.rb

Overview

View of a base configuration with a profile's option overrides applied. Everything not overridden (secrets, preprocessors, payload stores, logging) delegates to the base configuration, so all processors share those registries.

Overrides are applied through a real PatientHttp::Configuration so that each option's writer performs its own normalization. Readers whose value a writer derives from an overridden option are taken from that configuration as well, so an override cannot be half applied.

Constant Summary collapse

DERIVED_READERS =

Readers populated as a side effect of another option's writer.

{
  encryption_key: [:encryption, :decryption, :encryptor]
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(base_configuration, overrides) ⇒ ProfileConfiguration

Returns a new instance of ProfileConfiguration.



387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/patient_http/sidekiq/configuration.rb', line 387

def initialize(base_configuration, overrides)
  super(base_configuration)
  normalized = PatientHttp::Configuration.new(**overrides)
  readers = overrides.keys.flat_map { |key| [key.to_sym, *DERIVED_READERS[key.to_sym]] }.uniq
  readers.each do |reader|
    next unless normalized.respond_to?(reader)

    define_singleton_method(reader) do |*args, &block|
      normalized.public_send(reader, *args, &block)
    end
  end
end