提交 30767f98 编写于 作者: J Javan Makhmali 提交者: GitHub

Merge pull request #30623 from manojmj92/manojmj92-oo-key-patch

make documentation consistent with  KeyError message 
......@@ -24,7 +24,7 @@ module ActiveSupport
# To raise an exception when the value is blank, append a
# bang to the key name, like:
#
# h.dog! # => raises KeyError: key not found: :dog
# h.dog! # => raises KeyError: :dog is blank
#
class OrderedOptions < Hash
alias_method :_get, :[] # preserve the original #[] method
......@@ -46,7 +46,7 @@ def method_missing(name, *args)
bangs = name_string.chomp!("!")
if bangs
fetch(name_string.to_sym).presence || raise(KeyError.new("#{name_string} is blank."))
fetch(name_string.to_sym).presence || raise(KeyError.new(":#{name_string} is blank"))
else
self[name_string]
end
......
......@@ -1049,7 +1049,7 @@ If you want an exception to be raised when some key is blank, use the bang
version:
```ruby
Rails.application.credentials.some_api_key! # => raises KeyError: key not found: :some_api_key
Rails.application.credentials.some_api_key! # => raises KeyError: :some_api_key is blank
```
Additional Resources
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册