class Dry::Types::PredicateInferrer
PredicateInferrer
returns the list of predicates used by a type.
@api public
Constants
- ARRAY
- HASH
- NIL
- REDUCED_TYPES
- TYPE_TO_PREDICATE
Attributes
compiler[R]
@return [Compiler] @api private
Public Class Methods
new(registry = PredicateRegistry.new)
click to toggle source
@api private
# File lib/dry/types/predicate_inferrer.rb, line 209 def initialize(registry = PredicateRegistry.new) @compiler = Compiler.new(registry) end
Public Instance Methods
[](type)
click to toggle source
Infer predicate identifier from the provided type
@param [Type] type @return [Symbol]
@api private
# File lib/dry/types/predicate_inferrer.rb, line 219 def [](type) self.class.fetch_or_store(type) do predicates = compiler.visit(type.to_ast) if predicates.is_a?(::Hash) predicates else REDUCED_TYPES[predicates] || predicates end end end