Sha256: 127cbf5a1b0024271aebef3886aba81887ae068f01f8bfaa0b07212871171448
Contents?: true
Size: 600 Bytes
Versions: 2
Compression:
Stored size: 600 Bytes
Contents
module Polyfill module V2_6 module Struct def to_h return super unless block_given? block = ::Proc.new pairs = each_pair.map do |k, v| pair = block.call(k, v) unless pair.respond_to?(:to_ary) raise TypeError, "wrong element type #{pair.class} (expected array)" end pair = pair.to_ary unless pair.length == 2 raise ArgumentError, "element has wrong array length (expected 2, was #{pair.length})" end pair end pairs.to_h end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
polyfill-1.9.0 | lib/polyfill/v2_6/struct.rb |
polyfill-1.8.0 | lib/polyfill/v2_6/struct.rb |