Class: Dry::Schema::PrimitiveInferrer Private

Inherits:
Object
  • Object
show all
Extended by:
Core::Cache
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.

PrimitiveInferrer is used internally by ‘Macros::Filled` for inferring a list of possible primitives that a given type can handle.

Defined Under Namespace

Classes: Compiler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrimitiveInferrer

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.

Returns a new instance of PrimitiveInferrer.



82
83
84
# File 'lib/dry/schema/primitive_inferrer.rb', line 82

def initialize
  @compiler = Compiler.new
end

Instance Attribute Details

#compilerCompiler (readonly)

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.

Returns:



79
80
81
# File 'lib/dry/schema/primitive_inferrer.rb', line 79

def compiler
  @compiler
end

Instance Method Details

#[](type) ⇒ Symbol

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.

Infer predicate identifier from the provided type

Returns:

  • (Symbol)


91
92
93
94
95
# File 'lib/dry/schema/primitive_inferrer.rb', line 91

def [](type)
  self.class.fetch_or_store(type.hash) do
    Array(compiler.visit(type.to_ast)).freeze
  end
end