| Next | Pigs in Space | 12 |
For example, Pobox mailbox consumers expect an annual charge of $20 or $35
Then they eat it up over the ensuing 365 days
That's 5.479¢ per day
Moonpig::Role::Consumer::ChargesPeriodically makes sure they do the right thing
has last_charge_date => ( ... );
sub charge {
my ($self, $event) = @_;
my $now = $event->timestamp;
CHARGE: until ($self->next_charge_date->follows($now)) {
my $next = $self->next_charge_date;
$self->charge_one_day($next);
$self->last_charge_date($next);
if ($self->is_expired) {
$self->replacement->handle_event($event) if $self->replacement;
last CHARGE;
}
}
}
| Next | ![]() |
Copyright © 2013 M. J. Dominus |