Mercurial > pub > Impl
comparison Lib/IMPL/TypeKeyedCollection.pm @ 317:96a522aeb359
small fixes
author | cin |
---|---|
date | Thu, 09 May 2013 04:10:00 +0400 |
parents | 608beb8b3c6c |
children | de1f875e8875 |
comparison
equal
deleted
inserted
replaced
316:608beb8b3c6c | 317:96a522aeb359 |
---|---|
25 } | 25 } |
26 | 26 |
27 sub Get { | 27 sub Get { |
28 my ($this,$type) = @_; | 28 my ($this,$type) = @_; |
29 | 29 |
30 die ArgException->(type => 'Invalid type', $type) | 30 die ArgException->new(type => 'Invalid type', $type) |
31 if ref($type); | 31 if not $type or ref($type); |
32 | 32 |
33 if(my $val = $this->{$_cache}{$type}) { | 33 if(my $val = $this->{$_cache}{$type}) { |
34 return $val; | 34 return $val; |
35 } else { | 35 } else { |
36 no strict 'refs'; | 36 no strict 'refs'; |
40 while (@isa) { | 40 while (@isa) { |
41 my $sclass = shift @isa; | 41 my $sclass = shift @isa; |
42 | 42 |
43 $val = $this->{$_items}{$sclass}; | 43 $val = $this->{$_items}{$sclass}; |
44 | 44 |
45 return $this->{$_cache}{$type} = $val | 45 return($this->{$_cache}{$type} = $val) |
46 if defined $val; # zeroes and empty strings are also valid | 46 if defined $val; # zeroes and empty strings are also valid |
47 | 47 |
48 push @isa, @{"${sclass}::ISA"}; | 48 push @isa, @{"${sclass}::ISA"}; |
49 } | 49 } |
50 return; | 50 return; |
52 } | 52 } |
53 | 53 |
54 sub Set { | 54 sub Set { |
55 my ($this,$type,$value) = @_; | 55 my ($this,$type,$value) = @_; |
56 | 56 |
57 die ArgException->(type => 'Invalid type', $type) | 57 die ArgException->new(type => 'Invalid type', $type) |
58 if ref($type); | 58 if not $type or ref($type); |
59 | 59 |
60 $this->{$_items}{$type} = $value; | 60 $this->{$_items}{$type} = $value; |
61 | 61 |
62 delete $this->{$_cache}; | 62 delete $this->{$_cache}; |
63 | 63 |