aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-26 13:21:28 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-26 13:21:28 -0300
commitb1f6be9b5ea9eae4f6c5762852027d4808a037e2 (patch)
treef3782b6aa1531d89587720d19aca421f4a2ee580 /activesupport/lib/active_support
parent58ed699376f378f6d9b1a23484fcee4454ddaee5 (diff)
parente768c519fb6015e00961702a5165c6dab548a954 (diff)
downloadrails-b1f6be9b5ea9eae4f6c5762852027d4808a037e2.tar.gz
rails-b1f6be9b5ea9eae4f6c5762852027d4808a037e2.tar.bz2
rails-b1f6be9b5ea9eae4f6c5762852027d4808a037e2.zip
Merge pull request #20208 from gaurish/raise_on_missing_ordered_options
Add bang version to OrderedOptions
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/ordered_options.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb
index a33e2c58a9..ebf2a9bc29 100644
--- a/activesupport/lib/active_support/ordered_options.rb
+++ b/activesupport/lib/active_support/ordered_options.rb
@@ -31,7 +31,13 @@ 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 blank."))
+ else
+ self[name_string]
+ end
end
end