aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/except.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-21 04:00:51 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-21 04:39:53 -0700
commitb4a1718832c70005e45a930d5106857cf882e147 (patch)
treeb1a5fd3f934fd7142e26190a1192fbe371e7250b /activesupport/lib/active_support/core_ext/hash/except.rb
parentbc4e2aa931209e4d91779f15dbbf59b7db045dca (diff)
downloadrails-b4a1718832c70005e45a930d5106857cf882e147.tar.gz
rails-b4a1718832c70005e45a930d5106857cf882e147.tar.bz2
rails-b4a1718832c70005e45a930d5106857cf882e147.zip
Convert hash extension modules to class reopens
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/except.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/except.rb35
1 files changed, 13 insertions, 22 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/except.rb b/activesupport/lib/active_support/core_ext/hash/except.rb
index 949976d741..6d04cb5621 100644
--- a/activesupport/lib/active_support/core_ext/hash/except.rb
+++ b/activesupport/lib/active_support/core_ext/hash/except.rb
@@ -1,25 +1,16 @@
-require 'set'
-
-module ActiveSupport #:nodoc:
- module CoreExtensions #:nodoc:
- module Hash #:nodoc:
- # Return a hash that includes everything but the given keys. This is useful for
- # limiting a set of parameters to everything but a few known toggles:
- #
- # @person.update_attributes(params[:person].except(:admin))
- module Except
- # Returns a new hash without the given keys.
- def except(*keys)
- dup.except!(*keys)
- end
+class Hash
+ # Return a hash that includes everything but the given keys. This is useful for
+ # limiting a set of parameters to everything but a few known toggles:
+ #
+ # @person.update_attributes(params[:person].except(:admin))
+ def except(*keys)
+ dup.except!(*keys)
+ end
- # Replaces the hash without the given keys.
- def except!(*keys)
- keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
- keys.each { |key| delete(key) }
- self
- end
- end
- end
+ # Replaces the hash without the given keys.
+ def except!(*keys)
+ keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
+ keys.each { |key| delete(key) }
+ self
end
end