Sha256: d448c994f8550f5b9fb58245f441401a2b9618a22da920539f7e9cf07f241378

Contents?: true

Size: 666 Bytes

Versions: 1

Compression:

Stored size: 666 Bytes

Contents

module Polyfill
  module V2_4
    module Hash
      module TransformValues
        module Method
          def transform_values
            unless block_given?
              return Enumerator.new(keys.size) do |yielder|
                each_with_object({}) do |(k, v), acc|
                  acc[k] = yielder.yield(v)
                end
              end
            end

            each_with_object({}) do |(k, v), acc|
              acc[k] = yield(v)
            end
          end if RUBY_VERSION < '2.4.0'
        end

        if RUBY_VERSION < '2.4.0'
          refine ::Hash do
            include Method
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyfill-0.2.0 lib/polyfill/v2_4/hash/transform_values.rb