Bug 16842: Help for EDI accounts
[koha.git] / Koha / RecordProcessor / Base.pm
blob26edd8226f8d1b3aea63ffa4aa3b059e60abdddc
1 package Koha::RecordProcessor::Base;
3 # Copyright 2012 C & P Bibliography Services
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 =head1 NAME
22 Koha::RecordProcessor::Base - Base class for RecordProcessor filters
24 =head1 SYNOPSIS
26 use base qw(Koha::RecordProcessor::Base);
28 =head1 DESCRIPTION
30 Base class for record normalizer filters. RecordProcessors must
31 provide the following methods:
33 B<filter ($record)> - apply the filter and return the result. $record
34 may be either a scalar or an arrayref, and the return result will be
35 the same type.
37 The following variables must be defined in each filter:
38 our $NAME ='Filter';
39 our $VERSION = '1.0';
41 These methods may be overriden:
43 B<initialize (%params)> - initialize the filter
45 B<destroy ()> - destroy the filter
47 These methods should not be overridden unless you are very sure of what
48 you are doing:
50 B<new ()> - create a new filter object
52 Note that the RecordProcessor will not clone the record that is
53 passed in. If you do not want to change the original MARC::Record
54 object (or whatever type of object you are passing in), you must
55 clone it I<prior> to passing it off to the RecordProcessor.
57 =head1 FUNCTIONS
59 =cut
61 use strict;
62 use warnings;
64 use base qw(Class::Accessor);
66 __PACKAGE__->mk_ro_accessors(qw( name version ));
67 __PACKAGE__->mk_accessors(qw( params ));
68 our $NAME = 'Base';
71 =head2 new
73 my $filter = Koha::RecordProcessor::Base->new;
75 Create a new filter;
77 =cut
78 sub new {
79 my $class = shift;
81 my $self = $class->SUPER::new( { });#name => $class->NAME,
82 #version => $class->VERSION });
84 bless $self, $class;
85 return $self;
89 =head2 initialize
91 $filter->initalize(%params);
93 Initialize a filter using the specified parameters.
95 =cut
96 sub initialize {
97 my $self = shift;
98 my $params = shift;
100 $self->params($params);
102 return $self;
106 =head2 destroy
108 $filter->destroy();
110 Destroy the filter.
112 =cut
113 sub destroy {
114 my $self = shift;
115 return;
118 =head2 filter
120 my $newrecord = $filter->filter($record);
121 my $newrecords = $filter->filter(\@records);
123 Filter the specified record(s) and return the result.
125 =cut
126 sub filter {
127 my $self = shift;
128 my $record = shift;
129 return $record;