class Dry::Schema::Processor

@api public
@see JSON
@see Params
@see ProcessorSteps
Processing is split into steps represented by ‘ProcessorSteps`.
Processes input data using objects configured within the DSL

def call(input)

Other tags:
    Api: - public

Returns:
  • (Result) -

Parameters:
  • input (Hash) --
def call(input)
  Result.new(input.dup, message_compiler: message_compiler) do |result|
    steps.call(result)
  end
end

def config

Other tags:
    Api: - private

Returns:
  • (Dry::Types::Config) -
def config
  @config ||= rule_applier.config
end

def define(&block)

Other tags:
    Api: - public

Returns:
  • (Class) -

Other tags:
    See: Schema#JSON -
    See: Schema#Params -
    See: Schema#define -
def define(&block)
  @definition ||= DSL.new(
    processor_type: self, parent: superclass.definition, **config.to_h, &block
  )
  self
end

def filter_rules?

Other tags:
    Api: - private
def filter_rules?
  @filter_rules_predicate ||= schema_dsl.filter_rules?
end

def filter_schema

Other tags:
    Api: - private
def filter_schema
  @filter_schema ||= schema_dsl.filter_schema
end

def inspect

Other tags:
    Api: - public

Returns:
  • (String) -
def inspect
  <<~STR.strip
    #<#{self.class.name} keys=#{key_map.map(&:dump)} rules=#{rules.transform_values(&:to_s)}>
  STR
end

def key_map

Other tags:
    Api: - public

Returns:
  • (KeyMap) -
def key_map
  steps.key_map
end

def merge(other)

Other tags:
    Api: - public

Returns:
  • (Processor, Params, JSON) -

Parameters:
  • other (Processor) --
def merge(other)
  schema_dsl.merge(other.schema_dsl).()
end

def message_compiler

Other tags:
    Api: - private

Returns:
  • (MessageCompiler) -
def message_compiler
  rule_applier.message_compiler
end

def new(options = nil, &block)

Other tags:
    Api: - public

Returns:
  • (Processor) -
def new(options = nil, &block)
  if options || block
    processor = super(**(options || EMPTY_HASH))
    yield(processor) if block
    processor
  elsif definition
    definition.call
  else
    raise ArgumentError, "Cannot create a schema without a definition"
  end
end

def rule_applier

Other tags:
    Api: - private
def rule_applier
  steps.rule_applier
end

def rules

Other tags:
    Api: - private

Returns:
  • (MessageCompiler) -
def rules
  rule_applier.rules
end

def to_ast(*)

Other tags:
    Api: - private
def to_ast(*)
  rule_applier.to_ast
end

def to_proc

Other tags:
    Api: - public

Returns:
  • (Proc) -
def to_proc
  ->(input) { call(input) }
end

def type_schema

Other tags:
    Api: - private

Returns:
  • (Dry::Types::Safe) -
def type_schema
  steps.type_schema
end

def types

Other tags:
    Api: - private
def types
  schema_dsl.types
end

def xor(_other)

Other tags:
    Api: - public
def xor(_other)
  raise NotImplementedError, "composing schemas using `xor` operator is not supported yet"
end