You've already bought an entire Moose, use the antlers.
Create an anon class, hang onto it in the ::Report object - when it goes out of scope the package will be cleaned up, which will also nuke the class data result source. Then your DEMOLISH just needs to do $schema->unregister_source and you quite possibly won't leak any memory at all (or at least much less).
Or, y'know, you could just do { no strict 'refs'; @{"${class}::ISA"} = ('DBIx::Class::Core') } or if you want to be slightly "cleverer", base->import::into($class, 'DBIx::Class::Core') to duplicate the existing code (after loading Import::Into).
But unless you switch Moose to Moo, you might as well just use Moose
You've already bought an entire Moose, use the antlers.
Create an anon class, hang onto it in the ::Report object - when it goes out of scope the package will be cleaned up, which will also nuke the class data result source. Then your DEMOLISH just needs to do $schema->unregister_source and you quite possibly won't leak any memory at all (or at least much less).
Or, y'know, you could just do { no strict 'refs'; @{"${class}::ISA"} = ('DBIx::Class::Core') } or if you want to be slightly "cleverer", base->import::into($class, 'DBIx::Class::Core') to duplicate the existing code (after loading Import::Into).
But unless you switch Moose to Moo, you might as well just use Moose