Sha256: 445767b7954dfed0771f19b9821e7e01292de6c24f5806938ecd31d628dffd09

Contents?: true

Size: 473 Bytes

Versions: 1

Compression:

Stored size: 473 Bytes

Contents

# coding: utf-8

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

      def [](namespace, key)
        lookup = key
        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

1 entries across 1 versions & 1 rubygems

Version Path
confuse-1.0.0 lib/confuse/source/env.rb