aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/except.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-06-12 17:48:30 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-06-12 17:48:30 -0500
commitea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1 (patch)
treea3cce25be0c613a8e1444e1d0ff53aaed3497057 /activesupport/lib/active_support/core_ext/hash/except.rb
parent556204abaf95f7c995576cb1358f13de406682ab (diff)
parentdd4181f47dc0f166eb5d3e47a4a0dc1594cc5669 (diff)
downloadrails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.tar.gz
rails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.tar.bz2
rails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/except.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/except.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/except.rb b/activesupport/lib/active_support/core_ext/hash/except.rb
index 8362cd880e..bc97fa35a6 100644
--- a/activesupport/lib/active_support/core_ext/hash/except.rb
+++ b/activesupport/lib/active_support/core_ext/hash/except.rb
@@ -10,13 +10,14 @@ module ActiveSupport #:nodoc:
module Except
# Returns a new hash without the given keys.
def except(*keys)
- rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
- reject { |key,| rejected.include?(key) }
+ clone.except!(*keys)
end
# Replaces the hash without only the given keys.
def except!(*keys)
- replace(except(*keys))
+ keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
+ keys.each { |key| delete(key) }
+ self
end
end
end