Skip to content

Commit

Permalink
only loop over class callbacks that were valid for the initial data
Browse files Browse the repository at this point in the history
this could cause issues in cases where a class callback returned an
instance of an unrelated class, where that class also has a class
callback. when looping over the callbacks, it would be dependent on hash
ordering whether the new class was tried first (in which case it would
be ignored) or tried last (in which case it would be run). now, it
collects the class callbacks to run first, and then dies if it comes
across a replacement object that doesn't work for the callbacks that
were chosen.
  • Loading branch information
doy committed Jun 24, 2013
1 parent a4a734c commit 1a1ddc9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Data/Visitor/Callback.pm
Expand Up @@ -145,9 +145,10 @@ sub visit_object {

my $class_cb = 0;

foreach my $class ( @{ $self->class_callbacks } ) {
foreach my $class ( grep { $data->isa($_) } @{ $self->class_callbacks } ) {
last unless blessed($data);
next unless $data->isa($class);
die "Unexpected object $data found"
unless $data->isa($class);
$self->trace( flow => class_callback => $class, on => $data ) if DEBUG;

$class_cb++;
Expand Down

0 comments on commit 1a1ddc9

Please sign in to comment.