Sha256: e1a6461a3dc5911283d2956cc01b7187ff64e31ceb48b60036e05c38d28d505d
Contents?: true
Size: 688 Bytes
Versions: 7
Compression:
Stored size: 688 Bytes
Contents
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
7 entries across 7 versions & 1 rubygems