Sha256: 49a678b3ab186c3b69ecd4b0fe23779ea6b69ba143e8eef39f253af28b37122f

Contents?: true

Size: 821 Bytes

Versions: 1

Compression:

Stored size: 821 Bytes

Contents

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

              replace(each_with_object({}) do |(k, v), acc|
                acc[k] = yield(v)
              end)
            end
          end

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

            def self.included(base)
              base.include Method
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyfill-0.3.0 lib/polyfill/v2_4/hash/instance/transform_values_e.rb