File: array.rb

package info (click to toggle)
ruby-hashie 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: ruby: 7,049; sh: 8; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 520 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'hashie/extensions/array/pretty_inspect'
require 'hashie/extensions/ruby_version_check'

module Hashie
  class Array < ::Array
    include Hashie::Extensions::Array::PrettyInspect
    include Hashie::Extensions::RubyVersionCheck
    with_minimum_ruby('2.3.0') do
      def dig(*indexes)
        converted_indexes = indexes.map do |idx|
          begin
            Integer(idx)
          rescue ArgumentError
            idx
          end
        end
        super(*converted_indexes)
      end
    end
  end
end