[Koha-patches] [PATCH 2/2] Bug 14639: Extend Koha::MetadataRecord to handle serialization format

Tomas Cohen Arazi tomascohen at theke.io
Mon Aug 3 16:55:32 CEST 2015


The description of this changes is on the regression tests commit
message.

To test:
- Run
  $ prove t/Koha_MetadataRecord.t
=> FAIL: Tests fail because changes are not implemented
- Apply this patch
- Run
  $ prove t/Koha_MetadataRecord.t
=> SUCCESS: tests pass
- Run
  $ prove t/Koha_Util_MARC.t
=> SUCCESS: it still passes
- Sign off :-D
---
 Koha/MetadataRecord.pm | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/Koha/MetadataRecord.pm b/Koha/MetadataRecord.pm
index 865dc0d..1a00c9d 100644
--- a/Koha/MetadataRecord.pm
+++ b/Koha/MetadataRecord.pm
@@ -32,15 +32,39 @@ and authority) records in Koha.
 
 =cut
 
-use strict;
-use warnings;
-use C4::Context;
+use Modern::Perl;
+
+use Carp;
 use Koha::Util::MARC;
 
 use base qw(Class::Accessor);
 
-__PACKAGE__->mk_accessors(qw( record schema ));
+__PACKAGE__->mk_accessors(qw( record schema format ));
+
+
+sub new {
 
+    my $class  = shift;
+    my $params = shift;
+
+    if (!defined $params->{ record }) {
+        carp 'No record passed';
+        return;
+    }
+
+    my $record = $params->{ record };
+    my $schema = $params->{ schema } // 'marc21';
+    my $format = $params->{ format } // 'usmarc';
+
+    my $self = $class->SUPER::new({
+        record => $record,
+        schema => $schema,
+        format => $format
+    });
+
+    bless $self, $class;
+    return $self;
+}
 
 =head2 createMergeHash
 
-- 
2.5.0



More information about the Koha-patches mailing list