mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove extra conditions in HWIDA since Rails 6 does not support Ruby 2.2
See https://github.com/ruby/ruby/blob/ruby_2_3/NEWS
This commit is contained in:
parent
debe9a5cbe
commit
2bfef0d21f
2 changed files with 13 additions and 17 deletions
|
@ -177,20 +177,18 @@ module ActiveSupport
|
||||||
super(convert_key(key), *extras)
|
super(convert_key(key), *extras)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Hash.new.respond_to?(:dig)
|
# Same as <tt>Hash#dig</tt> where the key passed as argument can be
|
||||||
# Same as <tt>Hash#dig</tt> where the key passed as argument can be
|
# either a string or a symbol:
|
||||||
# either a string or a symbol:
|
#
|
||||||
#
|
# counters = ActiveSupport::HashWithIndifferentAccess.new
|
||||||
# counters = ActiveSupport::HashWithIndifferentAccess.new
|
# counters[:foo] = { bar: 1 }
|
||||||
# counters[:foo] = { bar: 1 }
|
#
|
||||||
#
|
# counters.dig('foo', 'bar') # => 1
|
||||||
# counters.dig('foo', 'bar') # => 1
|
# counters.dig(:foo, :bar) # => 1
|
||||||
# counters.dig(:foo, :bar) # => 1
|
# counters.dig(:zoo) # => nil
|
||||||
# counters.dig(:zoo) # => nil
|
def dig(*args)
|
||||||
def dig(*args)
|
args[0] = convert_key(args[0]) if args.size > 0
|
||||||
args[0] = convert_key(args[0]) if args.size > 0
|
super(*args)
|
||||||
super(*args)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Same as <tt>Hash#default</tt> where the key passed as argument can be
|
# Same as <tt>Hash#default</tt> where the key passed as argument can be
|
||||||
|
@ -228,7 +226,7 @@ module ActiveSupport
|
||||||
# hash.fetch_values('a', 'c') # => KeyError: key not found: "c"
|
# hash.fetch_values('a', 'c') # => KeyError: key not found: "c"
|
||||||
def fetch_values(*indices, &block)
|
def fetch_values(*indices, &block)
|
||||||
indices.collect { |key| fetch(key, &block) }
|
indices.collect { |key| fetch(key, &block) }
|
||||||
end if Hash.method_defined?(:fetch_values)
|
end
|
||||||
|
|
||||||
# Returns a shallow copy of the hash.
|
# Returns a shallow copy of the hash.
|
||||||
#
|
#
|
||||||
|
|
|
@ -169,8 +169,6 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_indifferent_fetch_values
|
def test_indifferent_fetch_values
|
||||||
skip unless Hash.method_defined?(:fetch_values)
|
|
||||||
|
|
||||||
@mixed = @mixed.with_indifferent_access
|
@mixed = @mixed.with_indifferent_access
|
||||||
|
|
||||||
assert_equal [1, 2], @mixed.fetch_values("a", "b")
|
assert_equal [1, 2], @mixed.fetch_values("a", "b")
|
||||||
|
|
Loading…
Reference in a new issue