Sha256: 65fea030f5cc135b47cf1939ac22a14b4beb229d4a6df8484ce59e14c481ff62
Contents?: true
Size: 949 Bytes
Versions: 3
Compression:
Stored size: 949 Bytes
Contents
# frozen_string_literal: true require "dry/core/equalizer" require "dry/schema/message/or/abstract" require "dry/schema/path" module Dry module Schema class Message module Or # A message type used by OR operations with different paths # # @api public class MultiPath < Abstract # @api private attr_reader :root # @api private def initialize(...) super flat_left = left.flatten flat_right = right.flatten @root = [*flat_left, *flat_right].map(&:_path).reduce(:&) @left = flat_left.map { _1.to_or(root) } @right = flat_right.map { _1.to_or(root) } end # @api public def to_h @to_h ||= Path[[*root, :or]].to_h( [MessageSet.new(left).to_h, MessageSet.new(right).to_h] ) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-schema-1.9.2 | lib/dry/schema/message/or/multi_path.rb |
dry-schema-1.9.1 | lib/dry/schema/message/or/multi_path.rb |
dry-schema-1.9.0 | lib/dry/schema/message/or/multi_path.rb |