Sha256: 830fbb96ba24f4bcc4a615cc629da74b43e13d5b681782370c3a0d57e0fc9420

Contents?: true

Size: 470 Bytes

Versions: 2

Compression:

Stored size: 470 Bytes

Contents

require 'yaml'

module Dry
  module Component
    class Config
      def self.load(root, name, env)
        path = root.join('config').join("#{name}.yml")

        return {} unless File.exist?(path)

        yaml = YAML.load_file(path)

        Class.new do
          extend Dry::Configurable

          yaml.fetch(env.to_s).each do |key, value|
            setting key.downcase.to_sym, ENV.fetch(key, value)
          end
        end.config
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-component-0.2.0 lib/dry/component/config.rb
dry-component-0.1.0 lib/dry/component/config.rb