aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorGaurish Sharma <contact@gaurishsharma.com>2015-05-17 16:21:34 +0530
committerGaurish Sharma <contact@gaurishsharma.com>2015-05-23 14:25:06 +0530
commite768c519fb6015e00961702a5165c6dab548a954 (patch)
tree00b4f408a6dd91c28f74efad7c64bc4f74bd0e07 /activesupport/lib/active_support
parent42e66fac38b54dd53d062fb5d3376218ed2ffdae (diff)
downloadrails-e768c519fb6015e00961702a5165c6dab548a954.tar.gz
rails-e768c519fb6015e00961702a5165c6dab548a954.tar.bz2
rails-e768c519fb6015e00961702a5165c6dab548a954.zip
Add bang version to OrderedOptions
By: Aditya Sanghi(@asanghi) Gaurish Sharma(gaurish)
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/ordered_options.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb
index a33e2c58a9..46c0da452d 100644
--- a/activesupport/lib/active_support/ordered_options.rb
+++ b/activesupport/lib/active_support/ordered_options.rb
@@ -31,7 +31,12 @@ module ActiveSupport
if name_string.chomp!('=')
self[name_string] = args.first
else
- self[name]
+ bangs = name_string.chomp!('!')
+ if bangs
+ fetch(name_string.to_sym).presence || raise(KeyError.new("#{name_string} is nil or undefined"))
+ else
+ self[name_string]
+ end
end
end