1
0
Fork 0
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:
bogdanvlviv 2018-02-17 18:16:15 +02:00 committed by Jeremy Daer
parent debe9a5cbe
commit 2bfef0d21f
2 changed files with 13 additions and 17 deletions

View file

@ -177,20 +177,18 @@ module ActiveSupport
super(convert_key(key), *extras)
end
if Hash.new.respond_to?(:dig)
# Same as <tt>Hash#dig</tt> where the key passed as argument can be
# either a string or a symbol:
#
# counters = ActiveSupport::HashWithIndifferentAccess.new
# counters[:foo] = { bar: 1 }
#
# counters.dig('foo', 'bar') # => 1
# counters.dig(:foo, :bar) # => 1
# counters.dig(:zoo) # => nil
def dig(*args)
args[0] = convert_key(args[0]) if args.size > 0
super(*args)
end
# Same as <tt>Hash#dig</tt> where the key passed as argument can be
# either a string or a symbol:
#
# counters = ActiveSupport::HashWithIndifferentAccess.new
# counters[:foo] = { bar: 1 }
#
# counters.dig('foo', 'bar') # => 1
# counters.dig(:foo, :bar) # => 1
# counters.dig(:zoo) # => nil
def dig(*args)
args[0] = convert_key(args[0]) if args.size > 0
super(*args)
end
# 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"
def fetch_values(*indices, &block)
indices.collect { |key| fetch(key, &block) }
end if Hash.method_defined?(:fetch_values)
end
# Returns a shallow copy of the hash.
#

View file

@ -169,8 +169,6 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase
end
def test_indifferent_fetch_values
skip unless Hash.method_defined?(:fetch_values)
@mixed = @mixed.with_indifferent_access
assert_equal [1, 2], @mixed.fetch_values("a", "b")