Revision c73b2658
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/DB/Object.pm | ||
---|---|---|
84 | 84 |
return $self->$sub(@_); |
85 | 85 |
} |
86 | 86 |
|
87 |
sub call_sub_if { |
|
88 |
my $self = shift; |
|
89 |
my $sub = shift; |
|
90 |
my $check = shift; |
|
91 |
|
|
92 |
$check = $check->($self) if ref($check) eq 'CODE'; |
|
93 |
|
|
94 |
return $check ? $self->$sub(@_) : $self; |
|
95 |
} |
|
96 |
|
|
87 | 97 |
1; |
88 | 98 |
|
89 | 99 |
__END__ |
... | ... | |
145 | 155 |
|
146 | 156 |
my $chart_id = $buchungsgruppe->call_sub(($is_sales ? "income" : "expense") . "_accno_id_${taxzone_id}"); |
147 | 157 |
|
158 |
=item C<call_sub_if $name, $check, @args> |
|
159 |
|
|
160 |
Calls the sub C<$name> on C<$self> with the arguments C<@args> if |
|
161 |
C<$check> is trueish. If C<$check> is a code reference then it will be |
|
162 |
called with C<$self> as the only argument and its result determines |
|
163 |
whether or not C<$name> is called. |
|
164 |
|
|
165 |
Returns the sub's result if the check is positive and C<$self> |
|
166 |
otherwise. |
|
167 |
|
|
148 | 168 |
=back |
149 | 169 |
|
150 | 170 |
=head1 AUTHOR |
Auch abrufbar als: Unified diff
Hilfsfunktion call_sub_if