[jifty-devel] Abstract record action type

Sterling Hanenkamp sterling at hanenkamp.com
Tue Jul 1 16:39:00 EDT 2008


Sometimes I find it useful to extend one of the Jifty::Action::Record::*
classes to create a new record-based action. Oddly, it seems that the most
useful one is Delete, which looks a little odd:

package MyApp::Action::StartTimer;
use base qw/ MyApp::Action::DeleteTimer /;

sub take_action {
    my $self = shift;
    $self->record->start_timer;
}

sub report_success {
    my $self = shift;
    $self->result->message(_('Started timer %1.', $self->record->name));
}

It looks a little strange to create an action like this, but the way that
the Delete takes a single record is exactly the right thing. I was thinking
of creating a new Jifty::Action::Record like like
Jifty::Action::Record::Basic or ::Simple that would be an abstract base that
would merely setup the arguments in the same way as ::Delete, but does not
define a take_action method. Then, after modifying the Classloader, you
could change the code above to start:

package MyApp::Action::StartTimer;
use base qw/ MyApp::Action::BasicTimer /;

Delete could then extend this as well. Is this a good idea, and anybody have
a vote for a better name?

Cheers,
Sterling
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jifty.org/pipermail/jifty-devel/attachments/20080701/11525ef4/attachment.htm 


More information about the jifty-devel mailing list