Sha256: ca1ac74a8ed9034e8f2e6a56f9c2e15adaec36bfeddfdb7130971b2bdc1be84f
Contents?: true
Size: 783 Bytes
Versions: 6
Compression:
Stored size: 783 Bytes
Contents
# frozen_string_literal: true require "dry/logic/operations/abstract" require "dry/logic/result" module Dry module Logic module Operations class Set < Abstract def type :set end def call(input) results = rules.map { |rule| rule.(input) } success = results.all?(&:success?) Result.new(success, id) do [type, results.select(&:failure?).map { |failure| failure.to_ast }] end end def [](input) rules.map { |rule| rule[input] }.all? end def ast(input = Undefined) [type, rules.map { |rule| rule.ast(input) }] end def to_s "#{type}(#{rules.map(&:to_s).join(", ")})" end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems