diff --git a/lib/tapioca/runtime/reflection.rb b/lib/tapioca/runtime/reflection.rb index 530b57a76..a17c67883 100644 --- a/lib/tapioca/runtime/reflection.rb +++ b/lib/tapioca/runtime/reflection.rb @@ -178,13 +178,19 @@ def descendants_of(klass) end # Examines the call stack to identify the closest location where a "require" is performed - # by searching for the label "". If none is found, it returns the location + # by searching for the label "" or "block in " in the + # case of an ActiveSupport.on_load hook. If none is found, it returns the location # labeled "
", which is the original call site. sig { params(locations: T.nilable(T::Array[Thread::Backtrace::Location])).returns(String) } def resolve_loc(locations) return "" unless locations - resolved_loc = locations.find { |loc| REQUIRED_FROM_LABELS.include?(loc.label) } + resolved_loc = locations.find do |loc| + label = loc.label + next unless label + + REQUIRED_FROM_LABELS.include?(label) || label.start_with?("block in