Module: Dry::Struct::Rails::StructRegistration
- Defined in:
- lib/dry/struct/rails/railtie.rb
Constant Summary collapse
- REGISTERED_STRUCTS =
Concurrent::Array.new
Instance Method Summary collapse
Instance Method Details
#attributes(new_schema) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dry/struct/rails/railtie.rb', line 7 def attributes(new_schema) unless StructRegistration::REGISTERED_STRUCTS.include?(self) # Check to see if we need to remove the registered type autoloaded = ActiveSupport::Dependencies.will_unload?(self) # 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/ } StructRegistration::REGISTERED_STRUCTS << self if autoloaded end super end |