Skip to content

Commit

Permalink
Sereal does not serialise code refs
Browse files Browse the repository at this point in the history
Updates #358 (even though it has been closed)
  • Loading branch information
shawnlaffan committed Sep 3, 2016
1 parent 6cf74d6 commit a68eb20
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/Biodiverse/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -831,11 +831,15 @@ sub save_to_sereal {

use Sereal::Encoder;

my $encoder = Sereal::Encoder->new();
my $out = $encoder->encode($self);
my $encoder = Sereal::Encoder->new({
undef_unknown => 1, # strip any code refs
});

open (my $fh, '>', $file) or die "Cannot open $file";
print {$fh} $out;

eval {
print {$fh} $encoder->encode($self);
};
my $e = $EVAL_ERROR;

$fh->close;
Expand Down

0 comments on commit a68eb20

Please sign in to comment.