From 2f79725466971fcc6580b3c69eb330e0ca3c76f8 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 8 Jul 2006 16:03:52 +0000 Subject: [PATCH] to_hash now accept parametars git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@56 4670fa4d-42ec-0310-ab5b-a66af6943492 --- lib/Biblio/Isis.pm | 17 ++++++++++++++++- t/2_isis.t | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/Biblio/Isis.pm b/lib/Biblio/Isis.pm index b11e856..a87994f 100644 --- a/lib/Biblio/Isis.pm +++ b/lib/Biblio/Isis.pm @@ -491,12 +491,26 @@ following structure: This method will also create additional field C<000> with MFN. +There is also more elaborative way to call C like this: + + my $hash = $isis->to_hash({ + mfn => 42, + include_empty_subfields => 1, + }); + =cut sub to_hash { my $self = shift; + my $mfn = shift || confess "need mfn!"; + my $arg; + + if (ref($mfn) eq 'HASH') { + $arg = $mfn; + $mfn = $arg->{mfn} || confess "need mfn in arguments"; + } # init record to include MFN as field 000 my $rec = { '000' => [ $mfn ] }; @@ -662,7 +676,8 @@ You can find version dependencies documented here =item 0.20 -Added C<< $isis->mfn >> and support for repeatable subfields +Added C<< $isis->mfn >>, support for repeatable subfields and +C<< $isis->to_hash({ mfn => 42, ... }) >> calling convention =back diff --git a/t/2_isis.t b/t/2_isis.t index de74585..a7b9405 100755 --- a/t/2_isis.t +++ b/t/2_isis.t @@ -3,7 +3,7 @@ use strict; use blib; -use Test::More tests => 128; +use Test::More tests => 130; use File::Spec; BEGIN { @@ -238,3 +238,5 @@ cmp_ok($ascii, 'eq', <<'__END_OF_ASCII__', 'to_ascii output'); __END_OF_ASCII__ +ok(my $hash2 = $isis->to_hash({ mfn => $isis->mfn }), 'to_hash(mfn)'); +is_deeply( $hash2, $hash, 'same hash' ); -- 2.20.1