Sha256: 94c2b0c0c9d6f7b0acd307d15257d2f7050c36354402276c1fbc94f4ea6e9e51
Contents?: true
Size: 774 Bytes
Versions: 2
Compression:
Stored size: 774 Bytes
Contents
module VmShepherd module BackportRefinements def self.should_refine? Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') end def self.ported_dig(obj, indices) head = indices.first new_obj = obj[head] if indices.count == 1 new_obj elsif new_obj == nil return nil else tail = indices[1..-1] ported_dig(new_obj, tail) end end refine Array do next unless BackportRefinements.should_refine? def dig(*indices) BackportRefinements.ported_dig(self, indices) end end refine Hash do next unless BackportRefinements.should_refine? def dig(*indices) BackportRefinements.ported_dig(self, indices) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vm_shepherd-3.0.0 | lib/vm_shepherd/backport_refinements.rb |
vm_shepherd-2.0.3 | lib/vm_shepherd/backport_refinements.rb |