Sha256: e013ff2ae2937627ebb604cee37e3f2a6647337abbe51852d44fbff05e6db5fb

Contents?: true

Size: 457 Bytes

Versions: 3

Compression:

Stored size: 457 Bytes

Contents

class Hashr < Hash
  module EnvDefaults
    def definition
      deep_enverize(super)
    end

    protected

      def deep_enverize(hash, nesting = ['WORKER'])
        hash.each do |key, value|
          nesting << key.to_s.upcase
          hash[key] = case value
          when Hash
            deep_enverize(value, nesting)
          else
            ENV.fetch(nesting.join('_'), value)
          end.tap { nesting.pop }
        end
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hashr-0.0.3 lib/hashr/env_defaults.rb
hashr-0.0.2 lib/hashr/env_defaults.rb
hashr-0.0.1 lib/hashr/env_defaults.rb