Module: WaterDrop::ConfigApplier

Defined in:
lib/water_drop/config_applier.rb

Overview

Engine used to propagate config application to DeliveryBoy with corner case handling

Class Method Summary collapse

Class Method Details

.call(delivery_boy_config, settings) ⇒ Object

Parameters:

  • delivery_boy_config (DeliveryBoy::Config)

    delivery boy config instance

  • settings (Hash)

    hash with WaterDrop settings



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/water_drop/config_applier.rb', line 9

def call(delivery_boy_config, settings)
  # Recursive lambda for mapping config down to delivery boy
  settings.each do |key, value|
    call(delivery_boy_config, value) && next if value.is_a?(Hash)

    # If this is a special case that needs manual setup instead of a direct reassignment
    if respond_to?(key, true)
      send(key, delivery_boy_config, value)
    else
      # If this setting is our internal one, we should not sync it with the delivery boy
      next unless delivery_boy_config.respond_to?(:"#{key}=")

      delivery_boy_config.public_send(:"#{key}=", value)
    end
  end
end