Skip to content

Instantly share code, notes, and snippets.

@benalavi
Created March 17, 2009 23:16
Show Gist options
  • Save benalavi/80819 to your computer and use it in GitHub Desktop.
Save benalavi/80819 to your computer and use it in GitHub Desktop.
require 'yaml'
class GlobalSettings < Hash
# TODO: take namespace as a param and get rid of rails dependency
def initialize(path)
raise "No settings yml file found (#{path})" unless File.exists?(path)
settings = (YAML.load_file(path) || {})[Rails.env] || {}
Rails.logger.info "WARNING: No settings loaded for environment #{Rails.env}" if settings.empty?
update settings.symbolize_keys
freeze
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment