Sha256: 9d03d7ff7cd92a6141ffced07bcfa8e2bf0a11179a53655de2c1e10863e61f55

Contents?: true

Size: 507 Bytes

Versions: 13

Compression:

Stored size: 507 Bytes

Contents

class Hash

  # Returns a new hash less the given keys.

  def except(*less_keys)
    slice(*keys - less_keys)
  end

  unless defined?(::ActiveSupport)

    # Replaces hash with new hash less the given keys.
    # This returns the hash of keys removed.
    #
    #   h = {:a=>1, :b=>2, :c=>3}
    #   h.except!(:a)  #=> {:a=>1}
    #   h              #=> {:b=>2,:c=>3}
    #
    def except!(*less_keys)
      removed = slice(*less_keys)
      replace(except(*less_keys))
      removed
    end

  end

end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
facets-2.8.4 lib/core/facets/hash/except.rb
facets-2.8.3 lib/core/facets/hash/except.rb
facets-2.8.2 lib/core/facets/hash/except.rb
facets-2.8.1 lib/core/facets/hash/except.rb
facets-2.8.0 lib/core/facets/hash/except.rb
facets-2.7.0 lib/core/facets/hash/except.rb
facets-2.6.0 lib/core/facets/hash/except.rb
facets-2.4.4 lib/core/facets/hash/except.rb
facets-2.5.0 lib/core/facets/hash/except.rb
facets-2.4.5 lib/core/facets/hash/except.rb
facets-2.5.1 lib/core/facets/hash/except.rb
facets-2.5.2 lib/core/facets/hash/except.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/hash/except.rb