Sha256: e8b16d9589dc806e8d8c2dfe7d49e455acaeb899b3807db7cafaacb738e722ac

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 Bytes

Contents

# This module handles initialization of the Configoro object, and contains some
# utility methods.

module Configoro

  # @return [Module] The Rails application namespace; e.g., @MyApp@ for a Rails
  #   app named @MyApp::Application@.

  def self.namespace
    Object.const_get Rails.application.class.to_s.split('::').first
  end

  # Creates the configuration dictionary and stores it under
  # @MyApp::Configuration@ (assuming an application named @MyApp@).

  def self.initialize
    namespace.const_set :Configuration, build_hash(Rails.env)
  end

  private

  def self.build_hash(env)
    config = Hash.new

    load_data config, 'common'
    load_data config, env

    config
  end

  def self.load_data(config, env)
    Dir.glob("#{Rails.root}/config/environments/#{env}/*.yml").sort.each { |file| config << file }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
configoro-1.1.0 lib/configoro/base.rb
configoro-1.0.0 lib/configoro/base.rb