From b4a1718832c70005e45a930d5106857cf882e147 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 21 Mar 2009 04:00:51 -0700 Subject: Convert hash extension modules to class reopens --- .../lib/active_support/core_ext/hash/except.rb | 35 ++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/hash/except.rb') 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 -- cgit v1.2.3