Sha256: b1b4997af45de33c0ccdf6ecfac8b135055108469166cfb1ddd9e546515f9f4f

Contents?: true

Size: 478 Bytes

Versions: 2

Compression:

Stored size: 478 Bytes

Contents

# coding: utf-8

module Confuse
  module Source
    class Env
      def initialize(options = {})
        @prefix = options[:prefix]
      end

      def [](namespace, key)
        lookup = key.to_s
        lookup = prepend(namespace, lookup) if namespace
        lookup = prepend(@prefix, lookup) if @prefix

        ENV[lookup.upcase]
      end

      private

      def prepend(pref, key)
        "#{pref}_#{key}" if pref
      end
    end

    register(:env, Env)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confuse-1.1.1 lib/confuse/source/env.rb
confuse-1.1.0 lib/confuse/source/env.rb