Class: Schemurai::VM::Evaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/schemurai/vm/evaluator.rb

Instance Method Summary collapse

Constructor Details

#initialize(graph, compiler, root, content: false, format: false) ⇒ Evaluator

Returns a new instance of Evaluator.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/schemurai/vm/evaluator.rb', line 57

def initialize(graph, compiler, root, content: false, format: false)
  @graph = graph
  @compiler = compiler
  @root = root
  @validate_content = content
  @validate_format = format
  @regexps = nil
  @active = nil
  @resolved_references = nil
  @decimals = nil
  @multiple_results = nil
  @dynamic_scope = nil
  @instance_path_buffer = nil
  @schema_path_buffer = nil
  @evaluation_pool = nil
  @evaluation_pool_index = 0
end

Instance Method Details

#backend ⇒ Object



55
# File 'lib/schemurai/vm/evaluator.rb', line 55

def backend = :vm

#valid?(instance) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
87
88
89
90
91
92
# File 'lib/schemurai/vm/evaluator.rb', line 84

def valid?(instance)
  @errors = nil
  @error_count = 0
  @dynamic_scope&.clear
  @instance_path = nil
  @schema_path = nil
  reset_evaluation_pool
  evaluate_valid(@root, instance)
end

#validate(instance) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/schemurai/vm/evaluator.rb', line 75

def validate(instance)
  @errors = []
  prepare_evaluation(paths: true)
  evaluate(@root, instance)
  Result.new(@errors)
ensure
  @errors = nil
end