Sha256: f21beefc6d6b31bd31194b7dd8db3bcf63d908bbf4166ff9d5655f82e50d420f

Contents?: true

Size: 987 Bytes

Versions: 3

Compression:

Stored size: 987 Bytes

Contents

require 'active_support/core_ext/module/attribute_accessors'
require 'rails_config/options'

require "rails_config/sources/yaml_source"

require 'rails_config/vendor/deep_merge' unless defined?(DeepMerge)

module RailsConfig
  # ensures the setup only gets run once
  @@_ran_once = false

  mattr_accessor :const_name
  @@const_name = "Settings"

  def self.setup
    yield self if @@_ran_once == false
    @@_ran_once = true
  end

  @@load_paths = []
  def self.load_paths
    @@load_paths
  end

  # Create a populated Options instance from a yaml file.  If a second yaml file is given, then the sections of that file will overwrite the sections
  # if the first file if they exist in the first file.
  def self.load_files(*files)
    config = Options.new

    # add yaml sources
    [files].flatten.compact.uniq.each do |file|
      config.add_source!(Sources::YAMLSource.new(file))
    end
    config.load!
    return config
  end

end

# add railtie
require 'rails_config/railtie'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_config-0.1.5 lib/rails_config.rb
rails_config-0.1.4 lib/rails_config.rb
rails_config-0.1.3 lib/rails_config.rb