fix 'Can't call method "setup" on an undefined value' error when using into rates...
[freeside.git] / FS / FS / cgp_rule_action.pm
1 package FS::cgp_rule_action;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::cgp_rule;
7
8 =head1 NAME
9
10 FS::cgp_rule_action - Object methods for cgp_rule_action records
11
12 =head1 SYNOPSIS
13
14   use FS::cgp_rule_action;
15
16   $record = new FS::cgp_rule_action \%hash;
17   $record = new FS::cgp_rule_action { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27 =head1 DESCRIPTION
28
29 An FS::cgp_rule_action object represents a mail filtering action.
30 FS::cgp_rule_action inherits from FS::Record.  The following fields are
31 currently supported:
32
33 =over 4
34
35 =item ruleactionnum
36
37 primary key
38
39 =item action
40
41 action
42
43 =item params
44
45 params
46
47 =item rulenum
48
49 rulenum
50
51 =back
52
53 =head1 METHODS
54
55 =over 4
56
57 =item new HASHREF
58
59 Creates a new action.  To add the action to the database, see L<"insert">.
60
61 Note that this stores the hash reference, not a distinct copy of the hash it
62 points to.  You can ask the object for a copy with the I<hash> method.
63
64 =cut
65
66 # the new method can be inherited from FS::Record, if a table method is defined
67
68 sub table { 'cgp_rule_action'; }
69
70 =item insert
71
72 Adds this record to the database.  If there is an error, returns the error,
73 otherwise returns false.
74
75 =cut
76
77 # the insert method can be inherited from FS::Record
78
79 =item delete
80
81 Delete this record from the database.
82
83 =cut
84
85 # the delete method can be inherited from FS::Record
86
87 =item replace OLD_RECORD
88
89 Replaces the OLD_RECORD with this one in the database.  If there is an error,
90 returns the error, otherwise returns false.
91
92 =cut
93
94 # the replace method can be inherited from FS::Record
95
96 =item check
97
98 Checks all fields to make sure this is a valid action.  If there is
99 an error, returns the error, otherwise returns false.  Called by the insert
100 and replace methods.
101
102 =cut
103
104 # the check method should currently be supplied - FS::Record contains some
105 # data checking routines
106
107 sub check {
108   my $self = shift;
109
110   my $error = 
111     $self->ut_numbern('ruleactionnum')
112     || $self->ut_text('action')
113     || $self->ut_textn('params')
114     || $self->ut_foreign_key('rulenum', 'cgp_rule', 'rulenum')
115   ;
116   return $error if $error;
117
118   $self->SUPER::check;
119 }
120
121 =item arrayref
122
123 =cut
124
125 sub arrayref {
126   my $self = shift;
127   [ $self->action, $self->params ];
128 }
129
130 =back
131
132 =head1 BUGS
133
134 =head1 SEE ALSO
135
136 L<FS::Record>, schema.html from the base documentation.
137
138 =cut
139
140 1;
141