diff options
author | Rishi Jain <rishi@joshsoftware.com> | 2014-11-03 17:08:50 +0530 |
---|---|---|
committer | Rishi Jain <rishi@joshsoftware.com> | 2014-11-04 09:08:57 +0530 |
commit | 78d4f2bcfb2bda48078766b7d7edf9b48e987851 (patch) | |
tree | b5dd9343bad00c2e0e21b44e484771c4b440fdee /activesupport | |
parent | 77c0256409d48c23b0b208f95191973e8c1dfd7f (diff) | |
download | rails-78d4f2bcfb2bda48078766b7d7edf9b48e987851.tar.gz rails-78d4f2bcfb2bda48078766b7d7edf9b48e987851.tar.bz2 rails-78d4f2bcfb2bda48078766b7d7edf9b48e987851.zip |
added example for hash slice method [ci skip]
Diffstat (limited to 'activesupport')
-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..41b2279013 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 valid keys before + # passing to a method: # # def search(criteria = {}) # criteria.assert_valid_keys(:mass, :velocity, :time) |