Class: Dry::Schema::PrimitiveInferrer::Compiler Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/schema/primitive_inferrer.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.

Compiler reduces type AST into a list of primitives

Instance Method Summary collapse

Instance Method Details

#visit(node) ⇒ 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.



20
21
22
23
# File 'lib/dry/schema/primitive_inferrer.rb', line 20

def visit(node)
  meth, rest = node
  public_send(:"visit_#{meth}", rest)
end

#visit_any(_) ⇒ 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.



72
73
74
# File 'lib/dry/schema/primitive_inferrer.rb', line 72

def visit_any(_)
  Object
end

#visit_array(_) ⇒ 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.



37
38
39
# File 'lib/dry/schema/primitive_inferrer.rb', line 37

def visit_array(_)
  Array
end

#visit_constrained(node) ⇒ 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.



66
67
68
69
# File 'lib/dry/schema/primitive_inferrer.rb', line 66

def visit_constrained(node)
  other, * = node
  visit(other)
end

#visit_constructor(node) ⇒ 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.



47
48
49
50
# File 'lib/dry/schema/primitive_inferrer.rb', line 47

def visit_constructor(node)
  other, * = node
  visit(other)
end

#visit_enum(node) ⇒ 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.



53
54
55
56
# File 'lib/dry/schema/primitive_inferrer.rb', line 53

def visit_enum(node)
  other, * = node
  visit(other)
end

#visit_hash(_) ⇒ 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.



32
33
34
# File 'lib/dry/schema/primitive_inferrer.rb', line 32

def visit_hash(_)
  Hash
end

#visit_lax(node) ⇒ 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.



42
43
44
# File 'lib/dry/schema/primitive_inferrer.rb', line 42

def visit_lax(node)
  visit(node)
end

#visit_nominal(node) ⇒ 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.



26
27
28
29
# File 'lib/dry/schema/primitive_inferrer.rb', line 26

def visit_nominal(node)
  type, _ = node
  type
end

#visit_sum(node) ⇒ 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.



59
60
61
62
63
# File 'lib/dry/schema/primitive_inferrer.rb', line 59

def visit_sum(node)
  left, right = node

  [visit(left), visit(right)].flatten(1)
end