lib/dry/schema.rb in dry-schema-1.10.6 vs lib/dry/schema.rb in dry-schema-1.11.0
- old
+ new
@@ -1,22 +1,43 @@
# frozen_string_literal: true
-require "dry/core/extensions"
+require "zeitwerk"
-require "dry/schema/config"
-require "dry/schema/constants"
-require "dry/schema/dsl"
-require "dry/schema/params"
-require "dry/schema/json"
+require "dry/core"
+require "dry/configurable"
+require "dry/logic"
+require "dry/types"
module Dry
# Main interface
#
# @api public
module Schema
extend Dry::Core::Extensions
+ # @api private
+ def self.loader
+ @loader ||= Zeitwerk::Loader.new.tap do |loader|
+ root = File.expand_path("..", __dir__)
+ loader.tag = "dry-schema"
+ loader.inflector = Zeitwerk::GemInflector.new("#{root}/dry-schema.rb")
+ loader.inflector.inflect(
+ "dsl" => "DSL",
+ "yaml" => "YAML",
+ "json" => "JSON",
+ "i18n" => "I18n"
+ )
+ loader.push_dir(root)
+ loader.ignore(
+ "#{root}/dry-schema.rb",
+ "#{root}/dry/schema/{constants,errors,version,extensions}.rb",
+ "#{root}/dry/schema/extensions"
+ )
+ loader.inflector.inflect("dsl" => "DSL")
+ end
+ end
+
# Configuration
#
# @example
# Dry::Schema.config.messages.backend = :i18n
#
@@ -82,9 +103,11 @@
#
# @api public
def self.JSON(**options, &block)
define(**options, processor_type: JSON, &block)
end
+
+ loader.setup
end
end
require "dry/schema/extensions"