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.



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

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.



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

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.



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

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.



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

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.



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

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

#visit_hash(_) ⇒ Object Also known as: visit_schema

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.



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

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.



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

def visit_sum(node)
  left, right = node

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