]>
Commit | Line | Data |
---|---|---|
0a580593 DM |
1 | package PMG::RuleDB::Group; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use Carp; | |
6 | use DBI; | |
7 | ||
8 | use PMG::RuleDB; | |
9 | ||
10 | # FIXME: log failures ? | |
11 | ||
12 | sub new { | |
13 | my ($type, $name, $info, $class) = @_; | |
14 | ||
15 | my $self = { | |
16 | name => $name, | |
17 | info => $info, | |
18 | class => $class, | |
19 | }; | |
20 | ||
21 | bless $self, $type; | |
22 | ||
23 | return $self; | |
24 | } | |
25 | ||
26 | sub gtype { | |
27 | my ($self, $str) = @_; | |
28 | ||
29 | if ($str eq "from") { return 0; } | |
30 | if ($str eq "to") { return 1; } | |
31 | if ($str eq "when") { return 2; } | |
32 | if ($str eq "what") { return 3; } | |
33 | if ($str eq "action") { return 4; } | |
34 | if ($str eq "greylist") { return 5; } | |
35 | ||
36 | return -1; | |
37 | } | |
38 | ||
39 | sub name { | |
40 | my ($self, $v) = @_; | |
41 | ||
42 | if (defined ($v)) { | |
43 | $self->{name} = $v; | |
44 | } | |
45 | ||
46 | $self->{name}; | |
47 | } | |
48 | ||
49 | sub info { | |
50 | my ($self, $v) = @_; | |
51 | ||
52 | if (defined ($v)) { | |
53 | $self->{info} = $v; | |
54 | } | |
55 | ||
56 | $self->{info}; | |
57 | } | |
58 | ||
59 | sub class { | |
60 | my ($self, $v) = @_; | |
61 | ||
62 | if (defined ($v)) { | |
63 | $self->{class} = $v; | |
64 | } | |
65 | ||
66 | $self->{class}; | |
67 | } | |
68 | ||
69 | sub id { | |
70 | my ($self, $v) = @_; | |
71 | ||
72 | if (defined ($v)) { | |
73 | $self->{id}=$v; | |
74 | } | |
75 | ||
76 | $self->{id}; | |
77 | } | |
78 | ||
79 | 1; |