Sha256: 05e4bfe11f322c4d5efe34dce229b58659d5edc9efe0d6ec8f23f3879586df82
Contents?: true
Size: 787 Bytes
Versions: 1
Compression:
Stored size: 787 Bytes
Contents
# frozen_string_literal: true require 'plumb/steppable' module Plumb class HashMap include Steppable attr_reader :key_type, :value_type def initialize(key_type, value_type) @key_type = key_type @value_type = value_type freeze end def call(result) failed = result.value.lazy.filter_map do |key, value| key_r = @key_type.resolve(key) value_r = @value_type.resolve(value) if !key_r.valid? [:key, key, key_r] elsif !value_r.valid? [:value, value, value_r] end end if (first = failed.next) field, val, halt = failed.first result.invalid(errors: "#{field} #{val.inspect} #{halt.errors}") end rescue StopIteration result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plumb-0.0.1 | lib/plumb/hash_map.rb |