Added hash_filter when using MARC::Fast 0.12
[webpac2] / lib / WebPAC / Input / MARC.pm
index c5f7b30..6002320 100644 (file)
@@ -3,7 +3,7 @@ package WebPAC::Input::MARC;
 use warnings;
 use strict;
 
-use MARC::Fast;
+use MARC::Fast 0.12;
 use base qw/WebPAC::Common/;
 use Carp qw/confess/;
 
@@ -56,10 +56,6 @@ sub new {
 
        my $db = new MARC::Fast(
                marcdb => $arg->{path},
-               hash_filter => sub {
-                       my ( $l, $nr ) = @_;
-                       Encode::decode( 'utf-8', $l );
-               },
        );
        my $db_size = $db->count - 1;   # FIXME
 
@@ -80,13 +76,13 @@ Return record with ID C<$mfn> from database
 sub fetch_rec {
        my $self = shift;
 
-       my $mfn = shift;
+       my ($mfn, $filter_coderef) = @_;
 
        if ($mfn > $self->{_marc_size}) {
                $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
        } else {
                my $marc = $self->{_marc_db} || confess "no _marc_db?";
-               my $row = $marc->to_hash($mfn, include_subfields => 1);
+               my $row = $marc->to_hash($mfn, include_subfields => 1, hash_filter => $filter_coderef);
                push @{$row->{'000'}}, $mfn;
                push @{$row->{'leader'}}, $marc->last_leader;
                return $row;