Sha256: bf4116e02b80dd2442a8dc6e916794f8ed7758101dec909ab30f9eb38bf7357d

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

module Dry
  module Schema
    # @api private
    class MessageCompiler
      # Optimized option hash used by visitor methods in message compiler
      #
      # @api private
      class VisitorOpts < Hash
        # @api private
        def self.new
          opts = super
          opts[:path] = EMPTY_ARRAY
          opts[:rule] = nil
          opts[:message_type] = :failure
          opts
        end

        # @api private
        def path
          self[:path]
        end

        # @api private
        def call(other)
          merge(other.update(path: [*path, *other[:path]]))
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-schema-0.1.1 lib/dry/schema/message_compiler/visitor_opts.rb
dry-schema-0.1.0 lib/dry/schema/message_compiler/visitor_opts.rb