diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2015-07-06 14:29:11 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2015-07-06 14:29:11 +0200 |
commit | c9ca063fcc4fd39ab1be1e894d88f53bd1afa5dd (patch) | |
tree | 79d80e759bbf49cdf2302a0074634d9f5b9c8335 | |
parent | 74c7246238960d82bbba450b1888ae2790e688d2 (diff) | |
parent | 912418fd0d5bed31176486b35e2690afbae122bb (diff) | |
download | rails-c9ca063fcc4fd39ab1be1e894d88f53bd1afa5dd.tar.gz rails-c9ca063fcc4fd39ab1be1e894d88f53bd1afa5dd.tar.bz2 rails-c9ca063fcc4fd39ab1be1e894d88f53bd1afa5dd.zip |
Merge pull request #20778 from maurogeorge/ordered_options_bang_doc
Add to RDoc of OrderedOptions the bang info [ci skip]
-rw-r--r-- | activesupport/lib/active_support/ordered_options.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index bc0326473d..45864990ce 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -6,6 +6,7 @@ module ActiveSupport # h[:girl] = 'Mary' # h[:boy] # => 'John' # h[:girl] # => 'Mary' + # h[:dog] # => nil # # Using +OrderedOptions+, the above code could be reduced to: # @@ -14,6 +15,13 @@ module ActiveSupport # h.girl = 'Mary' # h.boy # => 'John' # h.girl # => 'Mary' + # h.dog # => nil + # + # To raise an exception when the value is blank, append a + # bang to the key name, like: + # + # h.dog! # => raises KeyError + # class OrderedOptions < Hash alias_method :_get, :[] # preserve the original #[] method protected :_get # make it protected |