Class: Dry::Schema::TypeRegistry Private

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

A simple wrapper around Dry::Types registry

This is used internally by specialized processor sub-classes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types, namespace = :strict) ⇒ TypeRegistry

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 TypeRegistry.



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

def initialize(types, namespace = :strict)
  @types = types
  @namespace = namespace
end

Instance Attribute Details

#namespaceObject (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.



18
19
20
# File 'lib/dry/schema/type_registry.rb', line 18

def namespace
  @namespace
end

#typesObject (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.



15
16
17
# File 'lib/dry/schema/type_registry.rb', line 15

def types
  @types
end

Class Method Details

.new(types = Dry::Types, namespace = :strict) ⇒ 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.



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

def self.new(types = Dry::Types, namespace = :strict)
  super
end

Instance Method Details

#[](name) ⇒ 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
40
41
# File 'lib/dry/schema/type_registry.rb', line 37

def [](name)
  key = [namespace, name].compact.join(DOT)

  types.registered?(key) ? types[key] : types[name.to_s]
end

#namespaced(ns) ⇒ 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/type_registry.rb', line 32

def namespaced(ns)
  self.class.new(types, ns)
end