Sha256: 9b2239cab1c7303aad76b029dcd36ebe365a467ca161dc610d40a081f6581fcf

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

module Polyfill
  module V2_4
    module Hash
      module Instance
        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
          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.rb
polyfill-0.5.0 lib/polyfill/v2_4/hash/instance/transform_values.rb
polyfill-0.4.0 lib/polyfill/v2_4/hash/instance/transform_values.rb