def strict_merge_with_env(default:, local:, prefix:)
      hsh = {}

      default.each do |k, v|
        # The corresponding environment variable. If it's not the final value,
        # then this just contains the partial prefix of the env. variable.
        env = "#{prefix}_#{k}"

        # If the current value is a hash, then go deeper to perform a deep
        # merge, otherwise we merge the final value by respecting the order as
        # specified in the documentation.
        if v.is_a?(Hash)
          l = local[k] || {}
          hsh[k] = strict_merge_with_env(default: default[k], local: l, prefix: env)
        else
          hsh[k] = first_non_nil(get_env(env), local[k], v)
        end
      end
      hsh
    end
def strict_merge_with_env(default:, local:, prefix:)
      hsh = {}

      default.each do |k, v|
        # The corresponding environment variable. If it's not the final value,
        # then this just contains the partial prefix of the env. variable.
        env = "#{prefix}_#{k}"

        # If the current value is a hash, then go deeper to perform a deep
        # merge, otherwise we merge the final value by respecting the order as
        # specified in the documentation.
        if v.is_a?(Hash)
          l = local[k] || {}
          hsh[k] = strict_merge_with_env(default: default[k], local: l, prefix: env)
        else
          hsh[k] = first_non_nil(get_env(env), local[k], v)
        end
      end
      hsh
    end
Applies a deep merge while respecting the values from environment
 variables. A deep merge consists of a merge of all the nested elements of
 the two given hashes `config` and `local`. The `config` hash is supposed
 to contain all the accepted keys, and the `local` hash is a subset of it.

 Moreover, let's say that we have the following hash: { "ldap" => {
 "enabled" => true } }. An environment variable that can modify the value
 of the previous hash has to be named `#{prefix}_LDAP_ENABLED`. The `prefix`
 argument specifies how all the environment variables have to start.

 Returns the merged hash, where the precedence of the merge is as follows:
   1. The value of the related environment variable if set.
   2. The value from the `local` hash.
   3. The value from the `config` hash.