Skip to content

Instantly share code, notes, and snippets.

@smanolloff
Last active August 29, 2015 14:03
Show Gist options
  • Save smanolloff/c74ef634ca86249453e1 to your computer and use it in GitHub Desktop.
Save smanolloff/c74ef634ca86249453e1 to your computer and use it in GitHub Desktop.
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