module Dry::Types::Rails::TypesRegistration
Constants
- REGISTERED_TYPES
Public Instance Methods
register(name, type = nil, &block)
click to toggle source
Calls superclass method
# File lib/dry/types/rails/railtie.rb, line 7 def register(name, type = nil, &block) return super unless type return if TypesRegistration::REGISTERED_TYPES.include?(name) super.tap do # Check to see if we need to remove the registered type autoloaded = ActiveSupport::Dependencies.will_unload?(type) # ActiveSupport::Dependencies.will_unload?(klass) won't return true yet # if it's the first time a constant is being autoloaded # so we have to see if we're in the middle of loading a missing constants autoloaded |= caller.any? { |line| line =~ /\:in.*?new_constants_in/ } TypesRegistration::REGISTERED_TYPES << name if autoloaded end end