diff options
author | Zachary Scott <e@zzak.io> | 2014-11-03 19:43:48 -0800 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-11-03 19:43:48 -0800 |
commit | d73055025e3389beb9443c99aa3aee38e6345c49 (patch) | |
tree | ce07da2bcdb3858f8de958c66385bd6dbee0255f | |
parent | 77c0256409d48c23b0b208f95191973e8c1dfd7f (diff) | |
parent | 06467ad7fe880d8afba4c95d4558382d5db15ee3 (diff) | |
download | rails-d73055025e3389beb9443c99aa3aee38e6345c49.tar.gz rails-d73055025e3389beb9443c99aa3aee38e6345c49.tar.bz2 rails-d73055025e3389beb9443c99aa3aee38e6345c49.zip |
Merge pull request #17500 from rishijain/update_docs_4
added example for hash slice method [ci skip]
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/slice.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb index 8ad600b171..962655a6c1 100644 --- a/activesupport/lib/active_support/core_ext/hash/slice.rb +++ b/activesupport/lib/active_support/core_ext/hash/slice.rb @@ -1,6 +1,12 @@ class Hash - # Slice a hash to include only the given keys. This is useful for - # limiting an options hash to valid keys before passing to a method: + # Slice a hash to include only the given keys. Returns a hash containing + # the given keys. + # + # { a: 1, b: 2, c: 3, d: 4 }.slice(:a, :b) + # # => {:a=>1, :b=>2} + # + # This is useful for limiting an options hash to validate keys before + # passing to a method: # # def search(criteria = {}) # criteria.assert_valid_keys(:mass, :velocity, :time) |