Sha256: 88523a1b11ba66f56541d300e22f5cb6d13f15c9e409b26d99b43443b831a865

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 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

          refine ::Hash do
            include Method
          end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polyfill-0.6.0 lib/polyfill/v2_4/hash/instance/transform_values_e.rb
polyfill-0.5.0 lib/polyfill/v2_4/hash/instance/transform_values_e.rb
polyfill-0.4.0 lib/polyfill/v2_4/hash/instance/transform_values_e.rb