aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash
diff options
context:
space:
mode:
authorSebastian Martinez <sebastian@wyeworks.com>2011-08-15 20:20:28 -0300
committerSebastian Martinez <sebastian@wyeworks.com>2011-08-15 20:20:28 -0300
commit308595739c32609ac5b167ecdc6cb6cb4ec6c81f (patch)
treeae53554d3aae8eaced3a28e3986cad13b5435067 /activesupport/lib/active_support/core_ext/hash
parent583d7c15c301f15f1e997a06e15b55a2e7bf794f (diff)
downloadrails-308595739c32609ac5b167ecdc6cb6cb4ec6c81f.tar.gz
rails-308595739c32609ac5b167ecdc6cb6cb4ec6c81f.tar.bz2
rails-308595739c32609ac5b167ecdc6cb6cb4ec6c81f.zip
Document Hash#extract!.
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/slice.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb
index d7fb2da0fb..0484d8e5d8 100644
--- a/activesupport/lib/active_support/core_ext/hash/slice.rb
+++ b/activesupport/lib/active_support/core_ext/hash/slice.rb
@@ -30,6 +30,8 @@ class Hash
omit
end
+ # Removes and returns the key/value pairs matching the given keys.
+ # {:a => 1, :b => 2, :c => 3, :d => 4}.extract!(:a, :b) # => {:a => 1, :b => 2}
def extract!(*keys)
result = {}
keys.each {|key| result[key] = delete(key) }