root/trunk/lib/Mungo/Arbiter.pm

Revision 2, 1.1 kB (checked in by jesus, 7 years ago)

Initial import from Theo's private repository. From here on out it is open to the world.

Line 
1 package Mungo::Arbiter;
2
3 # Copyright (c) 2007 OmniTI Computer Consulting, Inc. All rights reserved.
4 # For information on licensing see:
5 #   https://labs.omniti.com/zetaback/trunk/LICENSE
6
7 sub __immutable {
8   my ($self, $key) = @_;
9   die "Mungo '$key' is immutable!\n";
10   return 0;
11 }
12 sub TIEHASH {
13   my $class = shift;
14   my $parent = shift;
15   my $data = shift;
16   return bless { 'Mungo' => $parent, data => $data }, $class;
17 }
18 sub UNTIE {
19   my $self = shift;
20   delete $self->{'Mungo'};
21 }
22 sub FIRSTKEY {
23   my $self = shift;
24   my $a = keys %{$self->{data}};
25   return each %{$self->{data}};
26 }
27 sub NEXTKEY {
28   my $self = shift;
29   return each %{$self->{data}};
30 }
31 sub FETCH {
32   my $self = shift;
33   my $key = shift;
34   return $self->{data}->{$key};
35 }
36 sub EXISTS {
37   my $self = shift;
38   my $key = shift;
39   return exists $self->{data}->{$key};
40 }
41 sub DELETE {
42   my $self = shift;
43   my @details = caller(1);
44   my $key = shift;
45   if($details[3] =~ /::cleanse$/) {
46     delete $self->{data}->{$key};
47   }
48 }
49 sub STORE {
50   my ($self, $key, $value) = @_;
51   my $cv = $self->check_map($key);
52   if(!$cv || $cv->($self,$key,$value)) {
53     $self->{data}->{$key} = $value;
54   }
55 }
56
57 1;
Note: See TracBrowser for help on using the browser.