Sha256: 05978b962c1c24db4f5b8acaa044e1201587f5077a1536e20b4aa78fdbca26ee
Contents?: true
Size: 719 Bytes
Versions: 6
Compression:
Stored size: 719 Bytes
Contents
# frozen_string_literal: true require "dry/logic/operations/unary" require "dry/logic/result" module Dry module Logic module Operations class Each < Unary def type :each end def call(input) results = input.map { |element| rule.(element) } success = results.all?(&:success?) Result.new(success, id) do failures = results .map .with_index { |result, idx| [:key, [idx, result.ast(input[idx])]] if result.failure? } .compact [:set, failures] end end def [](arr) arr.map { |input| rule[input] }.all? end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems