Skip to content

Commit

Permalink
enforce that importers can run only once
Browse files Browse the repository at this point in the history
  • Loading branch information
nics committed Oct 18, 2018
1 parent 909a5c5 commit 8633dd5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Catmandu/Importer.pm
Expand Up @@ -20,9 +20,13 @@ with 'Catmandu::Serializer';
around generator => sub {
my ($orig, $self) = @_;

return sub {} if $self->{_gen_created};
# importers can run only once
# TODO turn this into a role
state $exhausted = sub {};

$self->{_gen_created} = 1;
return $exhausted if $self->{__exhausted};

$self->{__exhausted} = 1;

my $generator = $orig->($self);

Expand Down

0 comments on commit 8633dd5

Please sign in to comment.