Bug 7674 - Followup - Add missing right-hand curly bracket
[koha.git] / Koha / RecordProcessor / Base.pm
1 package Koha::RecordProcessor::Base;
2
3 # Copyright 2012 C & P Bibliography Services
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 =head1 NAME
21
22 Koha::RecordProcessor::Base - Base class for RecordProcessor filters
23
24 =head1 SYNOPSIS
25
26   use base qw(Koha::RecordProcessor::Base);
27
28 =head1 DESCRIPTION
29
30 Base class for record normalizer filters. RecordProcessors must
31 provide the following methods:
32
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.
36
37 The following variables must be defined in each filter:
38   our $NAME ='Filter';
39   our $VERSION = '1.0';
40
41 These methods may be overriden:
42
43 B<initialize (%params)> - initialize the filter
44
45 B<destroy ()> - destroy the filter
46
47 These methods should not be overridden unless you are very sure of what
48 you are doing:
49
50 B<new ()> - create a new filter object
51
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.
56
57 =head1 FUNCTIONS
58
59 =cut
60
61 use strict;
62 use warnings;
63
64 use base qw(Class::Accessor);
65
66 __PACKAGE__->mk_ro_accessors(qw( name version ));
67 __PACKAGE__->mk_accessors(qw( params ));
68 our $NAME = 'Base';
69 our $VERSION = '1.0';
70
71
72 =head2 new
73
74     my $filter = Koha::RecordProcessor::Base->new;
75
76 Create a new filter;
77
78 =cut
79 sub new {
80     my $class = shift;
81
82     my $self = $class->SUPER::new( { });#name => $class->NAME,
83                                      #version => $class->VERSION });
84
85     bless $self, $class;
86     return $self;
87 }
88
89
90 =head2 initialize
91
92     $filter->initalize(%params);
93
94 Initialize a filter using the specified parameters.
95
96 =cut
97 sub initialize {
98     my $self = shift;
99     my $params = shift;
100
101     #$self->params = $params;
102
103     return $self;
104 }
105
106
107 =head2 destroy
108
109     $filter->destroy();
110
111 Destroy the filter.
112
113 =cut
114 sub destroy {
115     my $self = shift;
116     return;
117 }
118
119 =head2 filter
120
121     my $newrecord = $filter->filter($record);
122     my $newrecords = $filter->filter(\@records);
123
124 Filter the specified record(s) and return the result.
125
126 =cut
127 sub filter {
128     my $self = shift;
129     my $record = shift;
130     return $record;
131 }
132
133 1;