Sha256: 844369dac9a980dc7ad61ad870fa5e6479236deb5277840a78e68b54c0eb7f16

Contents?: true

Size: 762 Bytes

Versions: 26

Compression:

Stored size: 762 Bytes

Contents

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)
          rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
          reject { |key,| rejected.include?(key) }
        end

        # Replaces the hash without only the given keys.
        def except!(*keys)
          replace(except(*keys))
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 6 rubygems

Version Path
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
activesupport-2.0.1 lib/active_support/core_ext/hash/except.rb
activesupport-2.0.0 lib/active_support/core_ext/hash/except.rb
activesupport-2.0.2 lib/active_support/core_ext/hash/except.rb
activesupport-2.0.5 lib/active_support/core_ext/hash/except.rb
activesupport-2.1.0 lib/active_support/core_ext/hash/except.rb
activesupport-2.0.4 lib/active_support/core_ext/hash/except.rb
antfarm-0.3.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
antfarm-0.4.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/hash/except.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/hash/except.rb