Class: Dry::Types::PrimitiveInferrer

Inherits:
Object
  • Object
show all
Extended by:
Core::Cache
Defined in:
lib/dry/types/primitive_inferrer.rb

Overview

PrimitiveInferrer returns the list of classes matching a type.

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.



71
72
73
# File 'lib/dry/types/primitive_inferrer.rb', line 71

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:



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

def compiler
  @compiler
end

Instance Method Details

#[](type) ⇒ Array[Class]

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 primitives from the provided type

Returns:



80
81
82
83
84
# File 'lib/dry/types/primitive_inferrer.rb', line 80

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