Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use HashWithIndifferentAccess (if defined).

Stop wearing out your ":" key while writing YAML.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
  • Loading branch information...
commit 887186808511ba5fe86691856aed2cea2bf23ff9 1 parent 7b46035
@devpuppy devpuppy authored committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/app.rb
View
8 lib/app.rb
@@ -4,7 +4,11 @@
module App
VERSION = "0.2.2"
- @@config = {} # Initialize.
+ @@config = if Object.const_defined?(:HashWithIndifferentAccess)
+ HashWithIndifferentAccess.new
+ else
+ {}
+ end
class << self
# Returns the application configuration hash, as defined in
# "config/app.yml".
@@ -40,7 +44,7 @@ def method_missing(method, *args)
begin
raw = File.read Rails.root.join("config", "#{name.underscore}.yml")
all = YAML.load ERB.new(raw).result
- @@config = all[Rails.env] || all
+ @@config.update(all[Rails.env] || all)
@@config.freeze
rescue Errno::ENOENT => e
puts '** App: no file "config/app.yml". Run `script/generate app_config`.'
Please sign in to comment.
Something went wrong with that request. Please try again.