aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-08-03 18:10:57 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2015-08-03 18:10:57 +0200
commit351d62e0e8dbabb86ce04f1007d78d048e5fc72a (patch)
treec75141d4e88dc9c24c7eba34a3f7565aed493b9c /activesupport
parentbc3956c0d50630e6d537e3d3374671ed5e4e1f28 (diff)
parentb8d280b2dcacbff9ad8239d5ba4d099f25de540a (diff)
downloadrails-351d62e0e8dbabb86ce04f1007d78d048e5fc72a.tar.gz
rails-351d62e0e8dbabb86ce04f1007d78d048e5fc72a.tar.bz2
rails-351d62e0e8dbabb86ce04f1007d78d048e5fc72a.zip
Merge pull request #21087 from vngrs/fix_hash_except_doc
Fix the documentation of Hash#except method [ci skip]
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/except.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/except.rb b/activesupport/lib/active_support/core_ext/hash/except.rb
index 6e397abf51..2f6d38c1f6 100644
--- a/activesupport/lib/active_support/core_ext/hash/except.rb
+++ b/activesupport/lib/active_support/core_ext/hash/except.rb
@@ -1,8 +1,9 @@
class Hash
- # Returns a hash that includes everything but the given keys.
- # hash = { a: true, b: false, c: nil}
- # hash.except(:c) # => { a: true, b: false}
- # hash # => { a: true, b: false, c: nil}
+ # Returns a hash that includes everything except given keys.
+ # hash = { a: true, b: false, c: nil }
+ # hash.except(:c) # => { a: true, b: false }
+ # hash.except(:a, :b) # => { c: nil }
+ # hash # => { a: true, b: false, c: nil }
#
# This is useful for limiting a set of parameters to everything but a few known toggles:
# @person.update(params[:person].except(:admin))
@@ -10,10 +11,10 @@ class Hash
dup.except!(*keys)
end
- # Replaces the hash without the given keys.
- # hash = { a: true, b: false, c: nil}
- # hash.except!(:c) # => { a: true, b: false}
- # hash # => { a: true, b: false }
+ # Removes the given keys from hash and returns it.
+ # hash = { a: true, b: false, c: nil }
+ # hash.except!(:c) # => { a: true, b: false }
+ # hash # => { a: true, b: false }
def except!(*keys)
keys.each { |key| delete(key) }
self