diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-02-17 18:16:15 +0200 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2018-02-17 13:09:30 -0800 |
commit | 2bfef0d21f8e8ba666a0bccc82a722f339923c1d (patch) | |
tree | 16312b449deefefc562b705c135eb0ced2256f9c /activesupport/lib | |
parent | debe9a5cbe32dcf31580413ef73b811e8c8e13be (diff) | |
download | rails-2bfef0d21f8e8ba666a0bccc82a722f339923c1d.tar.gz rails-2bfef0d21f8e8ba666a0bccc82a722f339923c1d.tar.bz2 rails-2bfef0d21f8e8ba666a0bccc82a722f339923c1d.zip |
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
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/hash_with_indifferent_access.rb | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index eda7ec3940..e4afc8af93 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -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. # |