Sha256: be47356ec918c1611c7a4ebf895ecad90b4a9be231766a33330ad330b61c49d2

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'dry/schema/message'
require 'dry/schema/message_compiler'

require 'dry/schema/extensions/hints/message_compiler_methods'
require 'dry/schema/extensions/hints/message_set_methods'
require 'dry/schema/extensions/hints/result_methods'

module Dry
  module Schema
    # Hint-specific Message extensions
    #
    # @see Message
    #
    # @api public
    class Message
      # @see Message::Or
      #
      # @api public
      class Or
        # @api private
        def hint?
          false
        end
      end

      # @api private
      def hint?
        false
      end
    end

    # A hint message sub-type
    #
    # @api private
    class Hint < Message
      def self.[](predicate, path, text, options)
        Hint.new(predicate, path, text, options)
      end

      # @api private
      def hint?
        true
      end
    end

    module Extensions
      MessageCompiler.prepend(Hints::MessageCompilerMethods)
      MessageSet.prepend(Hints::MessageSetMethods)
      Result.prepend(Hints::ResultMethods)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-schema-0.4.0 lib/dry/schema/extensions/hints.rb
dry-schema-0.3.0 lib/dry/schema/extensions/hints.rb