Last active
August 29, 2015 14:03
-
-
Save smanolloff/c74ef634ca86249453e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
require 'recursive-open-struct' | |
# Read app.yml, users.yml and vendor.yml | |
%w(app users vendor).each do |name| | |
config = YAML.load_file("#{Rails.root}/config/#{name}.yml") || {} | |
struct = RecursiveOpenStruct.new(config, recurse_over_arrays: true) | |
Kernel.const_set("#{name}_config".camelize, struct) | |
end | |
# AppConfig, UsersConfig, VendorConfig, etc. now hold the configuration. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment