Ovid / dbix-class-report

Create arbitrary DBIx::Class resultsets on the fly
8 stars 2 forks source link

# XXX Again, I'll figure out something better after this hack #2

Open shadowcat-mst opened 8 years ago

shadowcat-mst commented 8 years ago

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