mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert [9209] Use Hash#except
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9210 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
adaed1ebcb
commit
3b603bbc93
3 changed files with 0 additions and 50 deletions
|
@ -1,7 +1,5 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
* Adding Hash#without Closes #7369 [eventualbuddha]
|
|
||||||
|
|
||||||
* TimeWithZone#method_missing: send to utc to advance with dst correctness, otherwise send to time. Adding tests for time calculations methods [Geoff Buesing]
|
* TimeWithZone#method_missing: send to utc to advance with dst correctness, otherwise send to time. Adding tests for time calculations methods [Geoff Buesing]
|
||||||
|
|
||||||
* Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [rick]
|
* Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [rick]
|
||||||
|
|
|
@ -11,11 +11,6 @@ module ActiveSupport #:nodoc:
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# search(options.slice(:mass, :velocity, :time))
|
# search(options.slice(:mass, :velocity, :time))
|
||||||
#
|
|
||||||
# Also allows leaving out certain keys. This is useful when duplicating
|
|
||||||
# a hash but omitting a certain subset:
|
|
||||||
#
|
|
||||||
# Event.new(event.attributes.without(:id, :user_id))
|
|
||||||
module Slice
|
module Slice
|
||||||
# Returns a new hash with only the given keys.
|
# Returns a new hash with only the given keys.
|
||||||
def slice(*keys)
|
def slice(*keys)
|
||||||
|
@ -27,17 +22,6 @@ module ActiveSupport #:nodoc:
|
||||||
def slice!(*keys)
|
def slice!(*keys)
|
||||||
replace(slice(*keys))
|
replace(slice(*keys))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a new hash without the given keys.
|
|
||||||
def without(*keys)
|
|
||||||
allowed = self.keys - (respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
|
|
||||||
slice(*allowed)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Replaces the hash without the given keys.
|
|
||||||
def without!(*keys)
|
|
||||||
replace(without(*keys))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -310,38 +310,6 @@ class HashExtTest < Test::Unit::TestCase
|
||||||
assert_equal expected, original.except!(:c)
|
assert_equal expected, original.except!(:c)
|
||||||
assert_equal expected, original
|
assert_equal expected, original
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_without
|
|
||||||
original = { :a => 'x', :b => 'y', :c => 10 }
|
|
||||||
expected = { :a => 'x' }
|
|
||||||
|
|
||||||
# Should return a hash without the given keys.
|
|
||||||
assert_equal expected, original.without(:b, :c)
|
|
||||||
assert_not_equal expected, original
|
|
||||||
|
|
||||||
# Should ignore non-existant keys.
|
|
||||||
assert_equal expected, original.without(:b, :c, :d)
|
|
||||||
|
|
||||||
# Should replace the hash with the given keys taken away.
|
|
||||||
assert_equal expected, original.without!(:b, :c)
|
|
||||||
assert_equal expected, original
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_indifferent_without
|
|
||||||
original = { :a => 'x', :b => 'y', :c => 10 }.with_indifferent_access
|
|
||||||
expected = { :c => 10 }.with_indifferent_access
|
|
||||||
|
|
||||||
[['a', 'b'], [:a, :b]].each do |keys|
|
|
||||||
# Should return a new hash without the given keys.
|
|
||||||
assert_equal expected, original.without(*keys), keys.inspect
|
|
||||||
assert_not_equal expected, original
|
|
||||||
|
|
||||||
# Should replace the hash without the given keys.
|
|
||||||
copy = original.dup
|
|
||||||
assert_equal expected, copy.without!(*keys)
|
|
||||||
assert_equal expected, copy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class IWriteMyOwnXML
|
class IWriteMyOwnXML
|
||||||
|
|
Loading…
Reference in a new issue