class Dry::Schema::Message::Or::MultiPath

def self.handler(message)

Other tags:
    Api: - private
def self.handler(message)
  case message
  when self
    IDENTITY
  when Array
    MESSAGE_ARRAY_HANDLER
  end
end

def _messages

Other tags:
    Api: - private
def _messages
  @_messages ||= [left, right].map do |message|
    handler = self.class.handler(message)
    unless handler
      raise ArgumentError,
            "#{message.inspect} is of unknown type #{message.class.inspect}"
    end
    handler.(message)
  end
end

def _path

Other tags:
    Api: - private
def _path
  @_path ||= Path[root]
end

def _paths

Other tags:
    Api: - private
def _paths
  @paths ||= _messages.flat_map(&:_paths)
end

def hint?

Other tags:
    Api: - private
def hint?
  false
end

def messages

Other tags:
    Api: - private
def messages
  @messages ||= _messages.flat_map { _1.to_or(root) }
end

def path

Other tags:
    Api: - private
def path
  root
end

def root

Other tags:
    Api: - private
def root
  @root ||= _paths.reduce(:&)
end

def to_h

Other tags:
    Api: - public
def to_h
  @to_h ||= Path[[*root, :or]].to_h(messages.map(&:to_h))
end

def to_or(root)

Other tags:
    Api: - private
def to_or(root)
  self.root == root ? messages : [self]
end