From 10bc9c4d50501e846e4a4e1b2bedb0f68b9fd4e1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 3 Aug 2015 11:41:23 -0300 Subject: [PATCH] Bug 14639: Extend Koha::MetadataRecord to handle serialization format 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