From 962ce60ff1692f6f2ed1a8322319d73b9790d324 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 23 Sep 2017 18:25:16 +0900 Subject: Make bang version work with `InheritableOptions` Currently, bang version does not work with `InheritableOptions`. `InheritableOptions` treats the argument Hash as the default value. However, `Hash#fetch` does not use the default value when key is not found, so can not get the default value. So in bang version, should use `Hash#[]` instead of `Hash#fetch`. --- activesupport/lib/active_support/ordered_options.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index c2a37fbdd7..b74510fdb2 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -46,7 +46,7 @@ module ActiveSupport bangs = name_string.chomp!("!") if bangs - fetch(name_string.to_sym).presence || raise(KeyError.new(":#{name_string} is blank")) + self[name_string].presence || raise(KeyError.new(":#{name_string} is blank")) else self[name_string] end -- cgit v1.2.3