Sha256: 9e71e25b432b37aa711a99cf0cf9be73a39baf40fa6bee9321e578a62187807f

Contents?: true

Size: 1019 Bytes

Versions: 15

Compression:

Stored size: 1019 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

        # Dump a message into a string
        #
        # @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

15 entries across 15 versions & 1 rubygems

Version Path
dry-schema-1.4.3 lib/dry/schema/message/or.rb
dry-schema-1.4.2 lib/dry/schema/message/or.rb
dry-schema-1.4.1 lib/dry/schema/message/or.rb
dry-schema-1.4.0 lib/dry/schema/message/or.rb
dry-schema-1.3.4 lib/dry/schema/message/or.rb
dry-schema-1.3.3 lib/dry/schema/message/or.rb
dry-schema-1.3.2 lib/dry/schema/message/or.rb
dry-schema-1.3.1 lib/dry/schema/message/or.rb
dry-schema-1.3.0 lib/dry/schema/message/or.rb
dry-schema-1.2.0 lib/dry/schema/message/or.rb
dry-schema-1.1.0 lib/dry/schema/message/or.rb
dry-schema-1.0.3 lib/dry/schema/message/or.rb
dry-schema-1.0.2 lib/dry/schema/message/or.rb
dry-schema-1.0.1 lib/dry/schema/message/or.rb
dry-schema-1.0.0 lib/dry/schema/message/or.rb