Class: Dry::Schema::RuleApplier Private

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Defined in:
lib/dry/schema/rule_applier.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Applies rules defined within the DSL

Instance Method Summary collapse

Instance Method Details

#call(input) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dry/schema/rule_applier.rb', line 24

def call(input)
  results = EMPTY_ARRAY.dup

  rules.each do |name, rule|
    next if input.error?(name)

    result = rule.(input.to_h)
    results << result if result.failure?
  end

  input.concat(results)
end

#to_astObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
42
43
44
# File 'lib/dry/schema/rule_applier.rb', line 38

def to_ast
  if config.messages.namespace
    [:namespace, [config.messages.namespace, [:set, rules.values.map(&:to_ast)]]]
  else
    [:set, rules.values.map(&:to_ast)]
  end
end