Sha256: 652c5d530b15647bce695dc332ab620717f914ddf7a25ee0584792c88f5cb282

Contents?: true

Size: 659 Bytes

Versions: 52

Compression:

Stored size: 659 Bytes

Contents

class Hash
  # Returns a hash that includes everything but the given keys.
  #   hash = { a: true, b: false, c: nil}
  #   hash.except(:c) # => { a: true, b: false}
  #   hash # => { a: true, b: false, c: nil}
  #
  # This is useful for limiting a set of parameters to everything but a few known toggles:
  #   @person.update(params[:person].except(:admin))
  def except(*keys)
    dup.except!(*keys)
  end

  # Replaces the hash without the given keys.
  #   hash = { a: true, b: false, c: nil}
  #   hash.except!(:c) # => { a: true, b: false}
  #   hash # => { a: true, b: false }
  def except!(*keys)
    keys.each { |key| delete(key) }
    self
  end
end

Version data entries

52 entries across 50 versions & 10 rubygems

Version Path
activesupport-4.2.11.3 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.11.2 lib/active_support/core_ext/hash/except.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/hash/except.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/hash/except.rb
activesupport-4.2.11.1 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.11 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.10 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.10.rc1 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.9 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.9.rc2 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.9.rc1 lib/active_support/core_ext/hash/except.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activesupport-4.2.8/lib/active_support/core_ext/hash/except.rb
activesupport-4.2.8 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.8.rc1 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.7.1 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.7 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.7.rc1 lib/active_support/core_ext/hash/except.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/core_ext/hash/except.rb
activesupport-4.2.6 lib/active_support/core_ext/hash/except.rb
activesupport-4.2.6.rc1 lib/active_support/core_ext/hash/except.rb