From aa2b447f99db794130ab167bb8f143b9357b83d8 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 30 Mar 2020 10:06:43 -0300 Subject: [PATCH] Bug 25008: Overload Koha::RecordProcessor->options to update filters This patch overloads the 'options' accessor generated by Class:Accessor. It does so the passed options are used to refresh the loaded filters. Tests are added for this overloaded method as well. To test: 1. Apply this patches 2. Run: $ kshell k$ prove t/RecordProcessor.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Jonathan Druart --- Koha/RecordProcessor.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Koha/RecordProcessor.pm b/Koha/RecordProcessor.pm index 1f93571d7b..a501c5010a 100644 --- a/Koha/RecordProcessor.pm +++ b/Koha/RecordProcessor.pm @@ -121,6 +121,29 @@ sub new { return $self; } +=head3 options + + $processor->options( $new_options ); + +Overloaded accessor, that spreads the new options to the filter objects when set + +=cut + +sub options { + my ( $self, $options ) = @_; + + if ( $options ) { # Set + foreach my $filter ( @{$self->filters} ) { + $filter->params->{options} = $options; + } + + $self->{options} = $options; + return $self; + } + + return $self->{options}; +} + =head2 bind $normalizer->bind($record) -- 2.20.1