From c3b0de4ec9a6e001769e4b61d090dc24dc52c419 Mon Sep 17 00:00:00 2001 From: Shawn Boyette Date: Mon, 20 Apr 2009 03:48:35 +0000 Subject: [PATCH] mods should return a hashref --- .../lib/Equinox/Migration/SubfieldMapper.pm | 8 ++++---- Equinox-Migration/t/02-SubfieldMapper.t | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Equinox-Migration/lib/Equinox/Migration/SubfieldMapper.pm b/Equinox-Migration/lib/Equinox/Migration/SubfieldMapper.pm index a282ca9..8ba8892 100644 --- a/Equinox-Migration/lib/Equinox/Migration/SubfieldMapper.pm +++ b/Equinox-Migration/lib/Equinox/Migration/SubfieldMapper.pm @@ -176,7 +176,7 @@ Returns the modifiers set on a mapping. $self->mods('fieldname') -If there are no modifiers, C will be returned. Else a listref +If there are no modifiers, C will be returned. Else a hashref will be returned. =cut @@ -271,12 +271,12 @@ sub add { my ($self, $map) = @_; # trim the mods and filters - my $mods = []; my %mods = (); + my $mods = {}; my $filt = []; my %filt = (); for my $m (@{$map->{mods}}) { - die "Modifier collision '$m' at line $." if $mods{$m}; + die "Modifier collision '$m' at line $." if $mods->{$m}; $m =~ s/^m://; - push @{$mods}, $m; $mods{$m} = 1; + $mods->{$m} = 1; } for my $f (@{$map->{filt}}) { die "Modifier collision '$f' at line $." if $filt{$f}; diff --git a/Equinox-Migration/t/02-SubfieldMapper.t b/Equinox-Migration/t/02-SubfieldMapper.t index 5fcf10f..e248bc0 100644 --- a/Equinox-Migration/t/02-SubfieldMapper.t +++ b/Equinox-Migration/t/02-SubfieldMapper.t @@ -90,10 +90,10 @@ is ($sm->field(650,'z'), undef, 'tag+code not mapped'); is ($sm->field(949,'a'), 'call_number', 'mapping returned'); # mod method tests -is ($sm->{fields}{note}{mods}[0], 'multi'); +is ($sm->{fields}{note}{mods}{multi}, 1); is ($sm->mods('zzz'), undef, 'nonexistant field'); -is_deeply ($sm->mods('note'), ['multi'], 'multi'); -is_deeply ($sm->mods('note_alt'), ['multi', 'req'], 'multi, req'); -is_deeply ($sm->mods('date_a'), ['foo', 'bar', 'quux']); +is_deeply ($sm->mods('note'), { multi => 1}, 'multi'); +is_deeply ($sm->mods('note_alt'), { multi => 1, req => 1 }, 'multi, req'); +is_deeply ($sm->mods('date_a'), { foo => 1, bar => 1, quux => 1 }); is_deeply ($sm->filters('date_a'), ['one two three']); -- 1.7.2.5