Sha256: 9d29f40c446e7eed09cb09bbf1bb1f81569ba4a2e3af46e6ba7b6e05001f0a0f

Contents?: true

Size: 346 Bytes

Versions: 2

Compression:

Stored size: 346 Bytes

Contents

module Yaks
  module FP

    class HashUpdatable < Module
      def initialize(*attributes)
        define_method :update do |updates|
          self.class.new(
            attributes.each_with_object({}) {|attr, hsh|
              hsh[attr] = updates.fetch(attr) { send(attr) }
            }
          )
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yaks-0.4.4 lib/yaks/fp/hash_updatable.rb
yaks-0.4.3 lib/yaks/fp/hash_updatable.rb