in reply to Re^12: How to completely destroy class attributes with Test::Most?
in thread How to completely destroy class attributes with Test::Most?
The key motivation for independent iterator objects is that they allow the program to have multiple iterators even on the same category by removing the need for the File::Collector object to track the iterators.
These "bundles" look a lot like independent iterators, and you could easily introduce an ->all method that returns a special object like so:
(in File::Collector::Iterator)
sub all { my $self = shift; bless \ $self, 'File::Collector::Iterator::All'; } { package File::Collector::Iterator::All; sub AUTOLOAD { our $AUTOLOAD; my $self = shift; $$self->$AUTOLOAD(@_) while ($$self->next_file); } }
This allows subclasses of File::Collector::Iterator to define their own "bundle actions" invokable as $iterator->all->$action. For example, a subclass that adds a delete action could contain simply:
sub delete { unlink (shift)->selected_file }
|
|---|