Sha256: a54c05f47e7b321291fefda0028f43bf8657a5620a770ae7f33a1a4febd0fe31

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

require 'yaml'
Configliere.use :define
module Configliere
  #
  # Environment -- load configuration from environment variables
  #
  module Environment
    def environment_variables *envs
      envs.each do |env|
        case env
        when Hash
          env.each do |env, param|
            adopt_environment_variable! env.to_s, param
          end
        else
          param = env.to_s.downcase.to_sym
          adopt_environment_variable! env.to_s, param
        end
      end
    end

    def params_from_environment
      definitions_for(:environment)
    end

  protected
    def adopt_environment_variable! env, param
      param_definitions[param][:environment] ||= env
      val = ENV[env]
      self[param] = val if val
    end
  end

  Param.class_eval do
    # include read / save operations
    include Environment
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
configliere-0.0.2 lib/configliere/environment.rb