Sha256: a8f1a897c865fa24fd4b4b177aff6ca54763726223c2b8216b191fc7a29218c8

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 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, param
          end
        else
          param = env.to_s.downcase.to_sym
          adopt_environment_variable! env, param
        end
      end
    end

    def adopt_environment_variable! env, param
      define param, :environment => env
      val = ENV[env]
      self[param] = val if val
    end

    def params_from_environment
      definitions_for(:environment)
    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.1 lib/configliere/environment.rb