class Dry::Schema::MessageCompiler::VisitorOpts

Optimized option hash used by visitor methods in message compiler

@api private

Public Class Methods

new() click to toggle source

@api private

Calls superclass method
# File lib/dry/schema/message_compiler/visitor_opts.rb, line 15
def self.new
  opts = super
  opts[:path] = EMPTY_ARRAY
  opts[:message_type] = :failure
  opts[:current_messages] = EMPTY_ARRAY.dup
  opts
end

Public Instance Methods

call(other) click to toggle source

@api private

# File lib/dry/schema/message_compiler/visitor_opts.rb, line 29
def call(other)
  merge(other.update(path: [*path, *other[:path]]))
end
current_messages() click to toggle source
# File lib/dry/schema/message_compiler/visitor_opts.rb, line 51
def current_messages
  self[:current_messages]
end
dup(current_messages = EMPTY_ARRAY.dup) click to toggle source
Calls superclass method
# File lib/dry/schema/message_compiler/visitor_opts.rb, line 33
def dup(current_messages = EMPTY_ARRAY.dup)
  opts = super()
  opts[:current_messages] = current_messages
  opts
end
failures() click to toggle source
# File lib/dry/schema/message_compiler/visitor_opts.rb, line 43
def failures
  current_messages.reject(&:hint?)
end
hints() click to toggle source
# File lib/dry/schema/message_compiler/visitor_opts.rb, line 47
def hints
  current_messages.select(&:hint?)
end
key_failure?(path) click to toggle source
# File lib/dry/schema/message_compiler/visitor_opts.rb, line 39
def key_failure?(path)
  failures.any? { |f| f.path == path && f.predicate.equal?(:key?) }
end
path() click to toggle source

@api private

# File lib/dry/schema/message_compiler/visitor_opts.rb, line 24
def path
  self[:path]
end