move data to $self->{'_lookup_data'} and document that
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 24 Jul 2005 14:20:59 +0000 (14:20 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 24 Jul 2005 14:20:59 +0000 (14:20 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@30 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Lookup.pm
t/1-lookup.t

index 47a49de..529706b 100644 (file)
@@ -3,8 +3,6 @@ package WebPAC::Lookup;
 use warnings;
 use strict;
 
-use WebPAC::Common;
-
 use base qw/WebPAC::Common WebPAC::Normalize/;
 use File::Slurp;
 use Data::Dumper;
@@ -42,6 +40,8 @@ value in lookup.
     'val' => 'v900' },
  ];
 
+Just for a reference, lookup data is internally stored in
+C<< $self->{'_lookup_data'} >>.
 
 =head1 FUNCTIONS
 
@@ -122,13 +122,13 @@ sub add($) {
                                my $key = $self->fill_in($rec,$i->{'key'}) || next;
                                my @val = $self->fill_in($rec,$i->{'val'}) || next;
                                $log->debug("stored $key = ",sub { join(" | ",@val) });
-                               push @{$self->{'lookup'}->{$key}}, @val;
+                               push @{$self->{'_lookup_data'}->{$key}}, @val;
                        }
                } else {
                        my $key = $self->fill_in($rec,$i->{'key'}) || next;
                        my @val = $self->fill_in($rec,$i->{'val'}) || next;
                        $log->debug("stored $key = ",sub { join(" | ",@val) });
-                       push @{$self->{'lookup'}->{$key}}, @val;
+                       push @{$self->{'_lookup_data'}->{$key}}, @val;
                }
        }
 
@@ -161,8 +161,8 @@ sub lookup {
                while (my $f = shift @in) {
                        if ($f =~ $self->{'LOOKUP_REGEX_SAVE'}) {
                                my $k = $1;
-                               if ($self->{'lookup'}->{$k}) {
-                                       foreach my $nv (@{$self->{'lookup'}->{$k}}) {
+                               if ($self->{'_lookup_data'}->{$k}) {
+                                       foreach my $nv (@{$self->{'_lookup_data'}->{$k}}) {
                                                my $tmp2 = $f;
                                                $tmp2 =~ s/lookup{$k}/$nv/g;
                                                push @in, $tmp2;
index cd7b4f2..a863fb4 100755 (executable)
@@ -33,7 +33,7 @@ diag "testing WebPAC::Lookup own methods";
 
 ok($lookup->add( $rec ), "add");
 
-ok($lookup->{'lookup'}, "have lookup hash");
+ok($lookup->{'_lookup_data'}, "have lookup hash");
 
 my $lookup_res = { 
        '800:foo' => [ 'bar' ],
@@ -41,7 +41,7 @@ my $lookup_res = {
        '900:bar' => [ 'FOO', 'foo' ]
 };
 
-is_deeply($lookup_res, $lookup->{'lookup'}, "lookup data");
+is_deeply($lookup_res, $lookup->{'_lookup_data'}, "lookup data");
 
 foreach my $k (keys %{ $lookup_res }) {
        ok(my @l = $lookup->lookup("lookup{$k}"), "lookup{$k}");