Sha256: d5bbee98062424a021ac009fa1c9920f455451b7ef3aa99c8fe90caf69692080

Contents?: true

Size: 900 Bytes

Versions: 19

Compression:

Stored size: 900 Bytes

Contents

# frozen_string_literal: true

require "dry/schema/constants"
require "dry/schema/types"

module Dry
  module Schema
    # A simple wrapper around Dry::Types registry
    #
    # This is used internally by specialized processor sub-classes
    #
    # @api private
    class TypeRegistry
      # @api private
      attr_reader :types

      # @api private
      attr_reader :namespace

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

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

      # @api private
      def namespaced(ns)
        self.class.new(types, ns)
      end

      # @api private
      def [](name)
        key = [namespace, name].compact.join(DOT)

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
dry-schema-1.13.3 lib/dry/schema/type_registry.rb
dry-schema-1.13.2 lib/dry/schema/type_registry.rb
dry-schema-1.13.1 lib/dry/schema/type_registry.rb
dry-schema-1.13.0 lib/dry/schema/type_registry.rb
dry-schema-1.12.0 lib/dry/schema/type_registry.rb
dry-schema-1.11.3 lib/dry/schema/type_registry.rb
dry-schema-1.11.2 lib/dry/schema/type_registry.rb
dry-schema-1.11.1 lib/dry/schema/type_registry.rb
dry-schema-1.11.0 lib/dry/schema/type_registry.rb
dry-schema-1.10.6 lib/dry/schema/type_registry.rb
dry-schema-1.10.5 lib/dry/schema/type_registry.rb
dry-schema-1.10.4 lib/dry/schema/type_registry.rb
dry-schema-1.10.3 lib/dry/schema/type_registry.rb
dry-schema-1.10.2 lib/dry/schema/type_registry.rb
dry-schema-1.10.1 lib/dry/schema/type_registry.rb
dry-schema-1.9.3 lib/dry/schema/type_registry.rb
dry-schema-1.9.2 lib/dry/schema/type_registry.rb
dry-schema-1.9.1 lib/dry/schema/type_registry.rb
dry-schema-1.9.0 lib/dry/schema/type_registry.rb