From d91b862716b8910f7f29f2b576dba4b4d25829e5 Mon Sep 17 00:00:00 2001 From: Nikita Shilnikov Date: Fri, 3 Jan 2025 21:43:24 +0100 Subject: [PATCH] Use :: for referencing top-level constants --- lib/dry/schema.rb | 8 ++--- lib/dry/schema/config.rb | 8 ++--- lib/dry/schema/constants.rb | 4 +-- lib/dry/schema/dsl.rb | 4 +-- .../extensions/json_schema/schema_compiler.rb | 2 +- lib/dry/schema/extensions/monads.rb | 2 +- lib/dry/schema/key.rb | 8 ++--- lib/dry/schema/key_coercer.rb | 2 +- lib/dry/schema/key_map.rb | 6 ++-- lib/dry/schema/key_validator.rb | 2 +- lib/dry/schema/macros/dsl.rb | 2 +- lib/dry/schema/message.rb | 8 ++--- lib/dry/schema/message_compiler.rb | 12 ++++---- lib/dry/schema/message_set.rb | 10 +++---- lib/dry/schema/messages/abstract.rb | 24 +++++++-------- lib/dry/schema/messages/namespaced.rb | 2 +- lib/dry/schema/messages/template.rb | 4 +-- lib/dry/schema/messages/yaml.rb | 2 +- lib/dry/schema/path.rb | 20 ++++++------- lib/dry/schema/predicate.rb | 8 ++--- lib/dry/schema/predicate_registry.rb | 4 +-- lib/dry/schema/processor.rb | 10 +++---- lib/dry/schema/processor_steps.rb | 2 +- lib/dry/schema/result.rb | 4 +-- lib/dry/schema/rule_applier.rb | 2 +- lib/dry/schema/trace.rb | 2 +- lib/dry/schema/type_container.rb | 4 +-- lib/dry/schema/type_registry.rb | 2 +- lib/dry/schema/types.rb | 2 +- lib/dry/schema/types_merger.rb | 30 +++++++++---------- lib/dry/schema/value_coercer.rb | 2 +- 31 files changed, 101 insertions(+), 101 deletions(-) diff --git a/lib/dry/schema.rb b/lib/dry/schema.rb index 3e1ea18a8..25d8a6bbe 100644 --- a/lib/dry/schema.rb +++ b/lib/dry/schema.rb @@ -12,14 +12,14 @@ module Dry # # @api public module Schema - extend Dry::Core::Extensions + extend ::Dry::Core::Extensions # @api private def self.loader - @loader ||= Zeitwerk::Loader.new.tap do |loader| - root = File.expand_path("..", __dir__) + @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 = ::Zeitwerk::GemInflector.new("#{root}/dry-schema.rb") loader.inflector.inflect( "dsl" => "DSL", "yaml" => "YAML", diff --git a/lib/dry/schema/config.rb b/lib/dry/schema/config.rb index af65984d2..75ba72e90 100644 --- a/lib/dry/schema/config.rb +++ b/lib/dry/schema/config.rb @@ -12,8 +12,8 @@ module Schema # # @api public class Config - include Dry::Configurable - include Dry::Equalizer(:to_h, inspect: false) + include ::Dry::Configurable + include ::Dry::Equalizer(:to_h, inspect: false) # @!method predicates # @@ -33,7 +33,7 @@ class Config # @return [Hash] # # @api public - setting :types, default: Dry::Types + setting :types, default: ::Dry::Types # @!method messages # @@ -45,7 +45,7 @@ class Config setting :messages do setting :backend, default: :yaml setting :namespace - setting :load_paths, default: Set[DEFAULT_MESSAGES_PATH], constructor: :dup.to_proc + setting :load_paths, default: ::Set[DEFAULT_MESSAGES_PATH], constructor: :dup.to_proc setting :top_namespace, default: DEFAULT_MESSAGES_ROOT setting :default_locale end diff --git a/lib/dry/schema/constants.rb b/lib/dry/schema/constants.rb index 8c38678be..4e80619b8 100644 --- a/lib/dry/schema/constants.rb +++ b/lib/dry/schema/constants.rb @@ -30,10 +30,10 @@ module Schema DEFAULT_MESSAGES_ROOT = "dry_schema" # An error raised when DSL is used in an incorrect way - InvalidSchemaError = Class.new(StandardError) + InvalidSchemaError = ::Class.new(::StandardError) # An error raised when a localized message cannot be found - MissingMessageError = Class.new(StandardError) do + MissingMessageError = ::Class.new(::StandardError) do # @api private def initialize(path, paths = []) *rest, rule = path diff --git a/lib/dry/schema/dsl.rb b/lib/dry/schema/dsl.rb index fd2154db2..f83139cf3 100644 --- a/lib/dry/schema/dsl.rb +++ b/lib/dry/schema/dsl.rb @@ -37,7 +37,7 @@ module Schema class DSL Types = Schema::Types - extend Dry::Initializer + extend ::Dry::Initializer # @return [Compiler] The type of the processor (Params, JSON, or a custom sub-class) option :processor_type, default: -> { Processor } @@ -501,7 +501,7 @@ def parent_key_map def default_config parents.each_cons(2) do |left, right| unless left.config == right.config - raise ArgumentError, + raise ::ArgumentError, "Parent configs differ, left=#{left.inspect}, right=#{right.inspect}" end end diff --git a/lib/dry/schema/extensions/json_schema/schema_compiler.rb b/lib/dry/schema/extensions/json_schema/schema_compiler.rb index 275cbbb57..663feb253 100644 --- a/lib/dry/schema/extensions/json_schema/schema_compiler.rb +++ b/lib/dry/schema/extensions/json_schema/schema_compiler.rb @@ -9,7 +9,7 @@ module JSONSchema # @api private class SchemaCompiler # An error raised when a predicate cannot be converted - UnknownConversionError = Class.new(StandardError) + UnknownConversionError = ::Class.new(::StandardError) IDENTITY = ->(v, _) { v }.freeze TO_INTEGER = ->(v, _) { v.to_i }.freeze diff --git a/lib/dry/schema/extensions/monads.rb b/lib/dry/schema/extensions/monads.rb index 008e402fe..6ed921162 100644 --- a/lib/dry/schema/extensions/monads.rb +++ b/lib/dry/schema/extensions/monads.rb @@ -11,7 +11,7 @@ module Schema # # @api public class Result - include Dry::Monads::Result::Mixin + include ::Dry::Monads::Result::Mixin # Turn result into a monad # diff --git a/lib/dry/schema/key.rb b/lib/dry/schema/key.rb index 184f571c3..57335af72 100644 --- a/lib/dry/schema/key.rb +++ b/lib/dry/schema/key.rb @@ -6,11 +6,11 @@ module Schema # # @api public class Key - extend Dry::Core::Cache + extend ::Dry::Core::Cache DEFAULT_COERCER = :itself.to_proc.freeze - include Dry.Equalizer(:name, :coercer) + include ::Dry.Equalizer(:name, :coercer) # @return [Symbol] The key identifier attr_reader :id @@ -90,7 +90,7 @@ def coerced_name # # @api private class Hash < self - include Dry.Equalizer(:name, :members, :coercer) + include ::Dry.Equalizer(:name, :members, :coercer) # @api private attr_reader :members @@ -137,7 +137,7 @@ def dump # # @api private class Array < self - include Dry.Equalizer(:name, :member, :coercer) + include ::Dry.Equalizer(:name, :member, :coercer) attr_reader :member diff --git a/lib/dry/schema/key_coercer.rb b/lib/dry/schema/key_coercer.rb index d9a6c374c..1524cae59 100644 --- a/lib/dry/schema/key_coercer.rb +++ b/lib/dry/schema/key_coercer.rb @@ -9,7 +9,7 @@ module Schema # # @api private class KeyCoercer - extend Dry::Core::Cache + extend ::Dry::Core::Cache include ::Dry::Equalizer(:key_map, :coercer) TO_SYM = :to_sym.to_proc.freeze diff --git a/lib/dry/schema/key_map.rb b/lib/dry/schema/key_map.rb index 86a40ae57..9b8119aa1 100644 --- a/lib/dry/schema/key_map.rb +++ b/lib/dry/schema/key_map.rb @@ -13,10 +13,10 @@ module Schema # # @api public class KeyMap - extend Dry::Core::Cache + extend ::Dry::Core::Cache - include Dry.Equalizer(:keys) - include Enumerable + include ::Dry.Equalizer(:keys) + include ::Enumerable # @return [Array] A list of defined key objects attr_reader :keys diff --git a/lib/dry/schema/key_validator.rb b/lib/dry/schema/key_validator.rb index e89da605c..e9ad86c60 100644 --- a/lib/dry/schema/key_validator.rb +++ b/lib/dry/schema/key_validator.rb @@ -7,7 +7,7 @@ module Dry module Schema # @api private class KeyValidator - extend Dry::Initializer + extend ::Dry::Initializer INDEX_REGEX = /\[\d+\]/ DIGIT_REGEX = /\A\d+\z/ diff --git a/lib/dry/schema/macros/dsl.rb b/lib/dry/schema/macros/dsl.rb index 525feba10..37ff42a48 100644 --- a/lib/dry/schema/macros/dsl.rb +++ b/lib/dry/schema/macros/dsl.rb @@ -7,7 +7,7 @@ module Macros # # @api public class DSL < Core - include Dry::Logic::Operators + include ::Dry::Logic::Operators undef :eql? undef :nil? diff --git a/lib/dry/schema/message.rb b/lib/dry/schema/message.rb index dd4fb7a59..e1035595e 100644 --- a/lib/dry/schema/message.rb +++ b/lib/dry/schema/message.rb @@ -8,9 +8,9 @@ module Schema # # @api public class Message - include Dry::Equalizer(:text, :path, :predicate, :input) + include ::Dry::Equalizer(:text, :path, :predicate, :input) - extend Dry::Initializer + extend ::Dry::Initializer # @!attribute [r] text # Message text representation created from a localized template @@ -75,7 +75,7 @@ def to_h # # @api private def eql?(other) - other.is_a?(String) ? text == other : super + other.is_a?(::String) ? text == other : super end # @api private @@ -94,7 +94,7 @@ def <=>(other) r_path = other._path unless l_path.same_root?(r_path) - raise ArgumentError, "Cannot compare messages from different root paths" + raise ::ArgumentError, "Cannot compare messages from different root paths" end l_path <=> r_path diff --git a/lib/dry/schema/message_compiler.rb b/lib/dry/schema/message_compiler.rb index f8d40287e..17f0b4d15 100644 --- a/lib/dry/schema/message_compiler.rb +++ b/lib/dry/schema/message_compiler.rb @@ -9,7 +9,7 @@ module Schema # # @api private class MessageCompiler - extend Dry::Initializer + extend ::Dry::Initializer resolve_key_predicate = proc { |node, opts| *arg_vals, val = node.map(&:last) @@ -20,12 +20,12 @@ class MessageCompiler [Array(opts.path), *node.map(&:last)] } - DEFAULT_PREDICATE_RESOLVERS = Hash + DEFAULT_PREDICATE_RESOLVERS = ::Hash .new(resolve_predicate).update(key?: resolve_key_predicate).freeze EMPTY_OPTS = VisitorOpts.new EMPTY_MESSAGE_SET = MessageSet.new(EMPTY_ARRAY).freeze - FULL_MESSAGE_WHITESPACE = Hash.new(" ").merge( + FULL_MESSAGE_WHITESPACE = ::Hash.new(" ").merge( ja: "", zh: "", bn: "", @@ -190,7 +190,7 @@ def visit_xor(node, opts) def lookup_options(arg_vals:, input:) default_lookup_options.merge( arg_type: arg_vals.size == 1 && arg_vals[0].class, - val_type: input.equal?(Undefined) ? NilClass : input.class + val_type: input.equal?(Undefined) ? ::NilClass : input.class ) end @@ -209,9 +209,9 @@ def message_text(template, tokens, options) def message_tokens(args) tokens = args.each_with_object({}) do |arg, hash| case arg[1] - when Array + when ::Array hash[arg[0]] = arg[1].join(LIST_SEPARATOR) - when Range + when ::Range hash["#{arg[0]}_left".to_sym] = arg[1].first hash["#{arg[0]}_right".to_sym] = arg[1].last else diff --git a/lib/dry/schema/message_set.rb b/lib/dry/schema/message_set.rb index 2d92753cd..e8f6b0b5a 100644 --- a/lib/dry/schema/message_set.rb +++ b/lib/dry/schema/message_set.rb @@ -10,8 +10,8 @@ module Schema # # @api public class MessageSet - include Enumerable - include Dry::Equalizer(:messages, :options) + include ::Enumerable + include ::Dry::Equalizer(:messages, :options) # A list of compiled message objects # @@ -82,7 +82,7 @@ def [](key) # # @api public def fetch(key) - self[key] || raise(KeyError, "+#{key}+ message was not found") + self[key] || raise(::KeyError, "+#{key}+ message was not found") end # Check if a message set is empty @@ -135,9 +135,9 @@ def combine_message_values(values) # @api private def partition_message_values(values) values - .map { |value| value.is_a?(Array) ? value : [value] } + .map { |value| value.is_a?(::Array) ? value : [value] } .reduce(EMPTY_ARRAY.dup, :+) - .partition { |value| value.is_a?(Hash) && !value[:text].is_a?(String) } + .partition { |value| value.is_a?(::Hash) && !value[:text].is_a?(::String) } end end end diff --git a/lib/dry/schema/messages/abstract.rb b/lib/dry/schema/messages/abstract.rb index 2200aa9c4..8f25b9d2b 100644 --- a/lib/dry/schema/messages/abstract.rb +++ b/lib/dry/schema/messages/abstract.rb @@ -12,11 +12,11 @@ module Messages # # @api public class Abstract - include Dry::Configurable - include Dry::Equalizer(:config) + include ::Dry::Configurable + include ::Dry::Equalizer(:config) setting :default_locale - setting :load_paths, default: Set[DEFAULT_MESSAGES_PATH] + setting :load_paths, default: ::Set[DEFAULT_MESSAGES_PATH] setting :top_namespace, default: DEFAULT_MESSAGES_ROOT setting :root, default: "errors" setting :lookup_options, default: %i[root predicate path val_type arg_type].freeze @@ -34,13 +34,13 @@ class Abstract setting :rule_lookup_paths, default: ["rules.%s"].freeze - setting :arg_types, default: Hash.new { |*| "default" }.update( - Range => "range" + setting :arg_types, default: ::Hash.new { |*| "default" }.update( + ::Range => "range" ) - setting :val_types, default: Hash.new { |*| "default" }.update( - Range => "range", - String => "string" + setting :val_types, default: ::Hash.new { |*| "default" }.update( + ::Range => "range", + ::String => "string" ) # @api private @@ -80,7 +80,7 @@ def rule(name, options = {}) path = rule_lookup_paths(tokens).detect { |key| key?(key, options) } rule = get(path, options) if path - rule.is_a?(Hash) ? rule[:text] : rule + rule.is_a?(::Hash) ? rule[:text] : rule end # Retrieve a message template @@ -115,7 +115,7 @@ def call(predicate, options) # # @api public def key?(_key, _options = EMPTY_HASH) - raise NotImplementedError + raise ::NotImplementedError end # Retrieve an array of looked up paths @@ -172,12 +172,12 @@ def default_locale # @api private def interpolatable_data(_key, _options, **_data) - raise NotImplementedError + raise ::NotImplementedError end # @api private def interpolate(_key, _options, **_data) - raise NotImplementedError + raise ::NotImplementedError end private diff --git a/lib/dry/schema/messages/namespaced.rb b/lib/dry/schema/messages/namespaced.rb index b2c522bc1..af124866f 100644 --- a/lib/dry/schema/messages/namespaced.rb +++ b/lib/dry/schema/messages/namespaced.rb @@ -6,7 +6,7 @@ module Messages # Namespaced messages backend # # @api public - class Namespaced < Dry::Schema::Messages::Abstract + class Namespaced < ::Dry::Schema::Messages::Abstract # @api private attr_reader :namespace diff --git a/lib/dry/schema/messages/template.rb b/lib/dry/schema/messages/template.rb index 51147096a..42622b7c3 100644 --- a/lib/dry/schema/messages/template.rb +++ b/lib/dry/schema/messages/template.rb @@ -10,8 +10,8 @@ module Schema module Messages # @api private class Template - extend Dry::Initializer - include Dry::Equalizer(:messages, :key, :options) + extend ::Dry::Initializer + include ::Dry::Equalizer(:messages, :key, :options) option :messages option :key diff --git a/lib/dry/schema/messages/yaml.rb b/lib/dry/schema/messages/yaml.rb index 541a4e4ac..5bea6c388 100644 --- a/lib/dry/schema/messages/yaml.rb +++ b/lib/dry/schema/messages/yaml.rb @@ -14,7 +14,7 @@ module Messages class YAML < Abstract LOCALE_TOKEN = "%s" TOKEN_REGEXP = /%{(\w*)}/ - EMPTY_CONTEXT = Object.new.tap { |ctx| + EMPTY_CONTEXT = ::Object.new.tap { |ctx| def ctx.context binding end diff --git a/lib/dry/schema/path.rb b/lib/dry/schema/path.rb index d51352e3a..f3ce95eda 100644 --- a/lib/dry/schema/path.rb +++ b/lib/dry/schema/path.rb @@ -8,9 +8,9 @@ module Schema # # @api private class Path - include Dry.Equalizer(:keys) - include Comparable - include Enumerable + include ::Dry.Equalizer(:keys) + include ::Comparable + include ::Enumerable # @return [Array] attr_reader :keys @@ -26,16 +26,16 @@ class Path # @api private def self.call(spec) case spec - when Symbol, Array - new(Array[*spec]) - when String + when ::Symbol, ::Array + new(::Array[*spec]) + when ::String new(spec.split(DOT).map(&:to_sym)) - when Hash + when ::Hash new(keys_from_hash(spec)) when self spec else - raise ArgumentError, "+spec+ must be either a Symbol, Array, Hash or a #{name}" + raise ::ArgumentError, "+spec+ must be either a Symbol, Array, Hash or a #{name}" end end @@ -49,7 +49,7 @@ def self.[](spec) # @api private def self.keys_from_hash(hash) hash.inject([]) { |a, (k, v)| - v.is_a?(Hash) ? a.concat([k, *keys_from_hash(v)]) : a.concat([k, v]) + v.is_a?(::Hash) ? a.concat([k, *keys_from_hash(v)]) : a.concat([k, v]) } end @@ -60,7 +60,7 @@ def initialize(keys) # @api private def to_h(value = EMPTY_ARRAY.dup) - value = [value] unless value.is_a?(Array) + value = [value] unless value.is_a?(::Array) keys.reverse_each.reduce(value) { |result, key| {key => result} } end diff --git a/lib/dry/schema/predicate.rb b/lib/dry/schema/predicate.rb index 06d6d4cce..7a6a0c826 100644 --- a/lib/dry/schema/predicate.rb +++ b/lib/dry/schema/predicate.rb @@ -13,7 +13,7 @@ class Predicate # # @api private class Negation - include Dry::Logic::Operators + include ::Dry::Logic::Operators # @api private attr_reader :predicate @@ -34,8 +34,8 @@ def to_ast(...) alias_method :ast, :to_ast end - include Dry::Logic::Operators - include Dry::Equalizer(:name, :args, :block) + include ::Dry::Logic::Operators + include ::Dry::Equalizer(:name, :args, :block) # @api private attr_reader :compiler @@ -77,7 +77,7 @@ def ! # @api private def ensure_valid if arity - 1 != args.size - raise ArgumentError, "#{name} predicate arity is invalid" + raise ::ArgumentError, "#{name} predicate arity is invalid" end end diff --git a/lib/dry/schema/predicate_registry.rb b/lib/dry/schema/predicate_registry.rb index 64a3e61c0..5ce60d66e 100644 --- a/lib/dry/schema/predicate_registry.rb +++ b/lib/dry/schema/predicate_registry.rb @@ -5,7 +5,7 @@ module Schema # A registry with predicate objects from `Dry::Logic::Predicates` # # @api private - class PredicateRegistry < Dry::Types::PredicateRegistry + class PredicateRegistry < ::Dry::Types::PredicateRegistry # @api private def arg_list(name, *values) predicate = self[name] @@ -15,7 +15,7 @@ def arg_list(name, *values) predicate .parameters .map(&:last) - .zip(values + Array.new(arity - values.size, Undefined)) + .zip(values + ::Array.new(arity - values.size, Undefined)) end end end diff --git a/lib/dry/schema/processor.rb b/lib/dry/schema/processor.rb index ca860d893..a52ada4c8 100644 --- a/lib/dry/schema/processor.rb +++ b/lib/dry/schema/processor.rb @@ -13,10 +13,10 @@ module Schema # # @api public class Processor - extend Dry::Initializer - extend Dry::Configurable + extend ::Dry::Initializer + extend ::Dry::Configurable - include Dry::Logic::Operators + include ::Dry::Logic::Operators setting :key_map_type setting :type_registry_namespace, default: :strict @@ -62,7 +62,7 @@ def new(options = nil, &block) elsif definition definition.call else - raise ArgumentError, "Cannot create a schema without a definition" + raise ::ArgumentError, "Cannot create a schema without a definition" end end end @@ -83,7 +83,7 @@ def call(input) # @api public def xor(_other) - raise NotImplementedError, "composing schemas using `xor` operator is not supported yet" + raise ::NotImplementedError, "composing schemas using `xor` operator is not supported yet" end alias_method :^, :xor diff --git a/lib/dry/schema/processor_steps.rb b/lib/dry/schema/processor_steps.rb index 3059824e1..6c774b5e7 100644 --- a/lib/dry/schema/processor_steps.rb +++ b/lib/dry/schema/processor_steps.rb @@ -19,7 +19,7 @@ module Schema # # @api public class ProcessorSteps - extend Dry::Initializer + extend ::Dry::Initializer option :steps, default: -> { EMPTY_HASH.dup } option :before_steps, default: -> { EMPTY_HASH.dup } diff --git a/lib/dry/schema/result.rb b/lib/dry/schema/result.rb index 3d0db0747..8674b85b6 100644 --- a/lib/dry/schema/result.rb +++ b/lib/dry/schema/result.rb @@ -11,9 +11,9 @@ module Schema # # @api public class Result - include Dry::Equalizer(:output, :errors) + include ::Dry::Equalizer(:output, :errors) - extend Dry::Initializer[undefined: false] + extend ::Dry::Initializer[undefined: false] # @api private param :output, reader: false diff --git a/lib/dry/schema/rule_applier.rb b/lib/dry/schema/rule_applier.rb index 45e5607e6..32cbfb44c 100644 --- a/lib/dry/schema/rule_applier.rb +++ b/lib/dry/schema/rule_applier.rb @@ -9,7 +9,7 @@ module Schema # # @api private class RuleApplier - extend Dry::Initializer + extend ::Dry::Initializer # @api private param :rules diff --git a/lib/dry/schema/trace.rb b/lib/dry/schema/trace.rb index 419c99b46..da331018b 100644 --- a/lib/dry/schema/trace.rb +++ b/lib/dry/schema/trace.rb @@ -5,7 +5,7 @@ module Schema # Captures predicates defined within the DSL # # @api private - class Trace < BasicObject + class Trace < ::BasicObject INVALID_PREDICATES = %i[key?].freeze include ::Dry::Equalizer(:compiler, :captures) diff --git a/lib/dry/schema/type_container.rb b/lib/dry/schema/type_container.rb index 5bb2aec30..b9c923389 100644 --- a/lib/dry/schema/type_container.rb +++ b/lib/dry/schema/type_container.rb @@ -13,9 +13,9 @@ module Schema # # @api public class TypeContainer - include Dry::Core::Container::Mixin + include ::Dry::Core::Container::Mixin - def initialize(types_container = Dry::Types.container) + def initialize(types_container = ::Dry::Types.container) super() merge(types_container) diff --git a/lib/dry/schema/type_registry.rb b/lib/dry/schema/type_registry.rb index 2a9fd8bd4..0b6c86694 100644 --- a/lib/dry/schema/type_registry.rb +++ b/lib/dry/schema/type_registry.rb @@ -18,7 +18,7 @@ class TypeRegistry attr_reader :namespace # @api private - def self.new(types = Dry::Types, namespace = :strict) + def self.new(types = ::Dry::Types, namespace = :strict) super end diff --git a/lib/dry/schema/types.rb b/lib/dry/schema/types.rb index 0938f5c1e..25d8fb72d 100644 --- a/lib/dry/schema/types.rb +++ b/lib/dry/schema/types.rb @@ -8,7 +8,7 @@ module Schema # # @api public module Types - include Dry.Types + include ::Dry.Types end end end diff --git a/lib/dry/schema/types_merger.rb b/lib/dry/schema/types_merger.rb index 198851f59..de97aeddb 100644 --- a/lib/dry/schema/types_merger.rb +++ b/lib/dry/schema/types_merger.rb @@ -27,14 +27,14 @@ def initialize(types_merger, op_class, old, new) # @api private def call - if op_class <= Dry::Logic::Operations::Or + if op_class <= ::Dry::Logic::Operations::Or merge_or - elsif op_class <= Dry::Logic::Operations::And + elsif op_class <= ::Dry::Logic::Operations::And merge_and - elsif op_class <= Dry::Logic::Operations::Implication + elsif op_class <= ::Dry::Logic::Operations::Implication merge_implication else - raise ArgumentError, <<~MESSAGE + raise ::ArgumentError, <<~MESSAGE Can't merge operations, op_class=#{op_class} MESSAGE end @@ -58,7 +58,7 @@ def merge_ordered rule = [old_rule, new_rule].compact.reduce { op_class.new(_1, _2) } - type = Dry::Types::Constrained.new(type, rule: rule) if rule + type = ::Dry::Types::Constrained.new(type, rule: rule) if rule type end @@ -71,11 +71,11 @@ def merge_ordered # @api private def merge_unwrapped_types(unwrapped_old, unwrapped_new) case [unwrapped_old, unwrapped_new] - in Dry::Types::Schema, Dry::Types::Schema + in ::Dry::Types::Schema, ::Dry::Types::Schema merge_schemas(unwrapped_old, unwrapped_new) - in [Dry::Types::AnyClass, _] | [Dry::Types::Hash, Dry::Types::Schema] + in [::Dry::Types::AnyClass, _] | [::Dry::Types::Hash, ::Dry::Types::Schema] unwrapped_new - in [Dry::Types::Schema, Dry::Types::Hash] | [_, Dry::Types::AnyClass] + in [::Dry::Types::Schema, ::Dry::Types::Hash] | [_, ::Dry::Types::AnyClass] unwrapped_old else merge_equivalent_types(unwrapped_old, unwrapped_new) @@ -100,27 +100,27 @@ def merge_unwrapped_types(unwrapped_old, unwrapped_new) # @api private def change_from_any?(unwrapped_old) - unwrapped_old.is_a?(Dry::Types::AnyClass) + unwrapped_old.is_a?(::Dry::Types::AnyClass) end # @api private def change_to_any?(unwrapped_new) - unwrapped_new.is_a?(Dry::Types::AnyClass) + unwrapped_new.is_a?(::Dry::Types::AnyClass) end # @api private def change_from_hash_to_schema?(unwrapped_old, unwrapped_new) - unwrapped_old.is_a?(Dry::Types::Hash) && unwrapped_new.is_a?(Dry::Types::Schema) + unwrapped_old.is_a?(::Dry::Types::Hash) && unwrapped_new.is_a?(::Dry::Types::Schema) end # @api private def change_from_schema_to_hash?(unwrapped_old, unwrapped_new) - unwrapped_old.is_a?(Dry::Types::Schema) && unwrapped_new.is_a?(Dry::Types::Hash) + unwrapped_old.is_a?(::Dry::Types::Schema) && unwrapped_new.is_a?(::Dry::Types::Hash) end # @api private def change_from_schema_to_schema?(unwrapped_old, unwrapped_new) - unwrapped_old.is_a?(Dry::Types::Schema) && unwrapped_new.is_a?(Dry::Types::Schema) + unwrapped_old.is_a?(::Dry::Types::Schema) && unwrapped_new.is_a?(::Dry::Types::Schema) end end @@ -142,7 +142,7 @@ def merge_equivalent_types(unwrapped_old, unwrapped_new) elsif unwrapped_new.primitive <= unwrapped_old.primitive unwrapped_old else - raise ArgumentError, <<~MESSAGE + raise ::ArgumentError, <<~MESSAGE Can't merge types, unwrapped_old=#{unwrapped_old.inspect}, unwrapped_new=#{unwrapped_new.inspect} MESSAGE end @@ -157,7 +157,7 @@ def unwrap_type(type) if type.optional? type = type.left.primitive?(nil) ? type.right : type.left - elsif type.is_a?(Dry::Types::Decorator) + elsif type.is_a?(::Dry::Types::Decorator) type = type.type else break diff --git a/lib/dry/schema/value_coercer.rb b/lib/dry/schema/value_coercer.rb index 093e15119..bb51f4c49 100644 --- a/lib/dry/schema/value_coercer.rb +++ b/lib/dry/schema/value_coercer.rb @@ -9,7 +9,7 @@ module Schema # # @api private class ValueCoercer - extend Dry::Initializer + extend ::Dry::Initializer include ::Dry::Equalizer(:type_schema) # @api private