Sha256: 16154bb65fea5aa1b53d66fbb4f7d7fd7e028265ee1a8b31bcd33c41a8b6b13c

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

require 'dry/equalizer'

module Dry
  module Schema
    # Message objects used by message sets
    #
    # @api public
    class Message
      # A message sub-type used by OR operations
      #
      # @api public
      class Or
        # @api private
        attr_reader :left

        # @api private
        attr_reader :right

        # @api private
        attr_reader :path

        # @api private
        attr_reader :messages

        # @api private
        def initialize(left, right, messages)
          @left = left
          @right = right
          @messages = messages
          @path = left.path
        end

        # @see Message#dump
        #
        # @return [String]
        #
        # @api public
        def dump
          to_a.map(&:dump).join(" #{messages[:or][:text]} ")
        end
        alias to_s dump

        # @api private
        def to_a
          [left, right]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-schema-0.6.0 lib/dry/schema/message/or.rb
dry-schema-0.5.1 lib/dry/schema/message/or.rb
dry-schema-0.5.0 lib/dry/schema/message/or.rb