in reply to Re^15: How to completely destroy class attributes with Test::Most?
in thread How to completely destroy class attributes with Test::Most?
Ok, I think I might be on to something good...or it could be colossally stupid, I'm not sure which. If I could indulge your attention for a little bit more, I'd appreciate it.
So check this out:
# prints out short name of all "txt-files" $da->bundle_txt_files->do->print_short_names;
And here is the iterator built using your suggestions (I changed the "all" method name to "do," which seemed to make more sense):
package File::Collector::Iterator ; use strict; use warnings; use Carp; use Log::Log4perl::Shortcuts qw(:all); my $collector; # private package variable for storing the Fi +le::Collector sub print_short_names { my $s = shift; print $collector->{files}{$s->selected_file}{short_path} . "\n"; # + uses the File::Collector object to look up short path } sub new { my $class = shift; $collector = shift; # new gets passed the $collector from File: +:Collector AUTOLOAD bless [@_], $class; } sub next { my $self = shift; shift @$self; return $self->[0]; } sub selected_file { (shift)->[0] } # do method of executing methods on child classes sub do { my $self = shift; bless \$self, 'File::Collector::Iterator::All'; } { package File::Collector::Iterator::All; use Log::Log4perl::Shortcuts qw(:all); sub AUTOLOAD { our $AUTOLOAD; my $self = shift; my @method = split /::/, $AUTOLOAD; my $method = pop @method; $$self->$method(@_) while ($$self->next); } }
What do you think? Is this a good solution?
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^17: How to completely destroy class attributes with Test::Most?
by jcb (Parson) on Aug 29, 2019 at 23:07 UTC | |
by nysus (Parson) on Aug 29, 2019 at 23:22 UTC | |
by jcb (Parson) on Aug 29, 2019 at 23:45 UTC | |
by nysus (Parson) on Aug 30, 2019 at 15:11 UTC | |
by jcb (Parson) on Aug 30, 2019 at 23:59 UTC | |
by nysus (Parson) on Aug 30, 2019 at 05:11 UTC | |
by jcb (Parson) on Aug 30, 2019 at 23:54 UTC | |
|