[Catalyst-commits] r11028 - in
Catalyst-Plugin-RunAfterRequest/trunk: . lib/Catalyst/Plugin
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Wed Aug 5 12:56:11 GMT 2009
Author: rafl
Date: 2009-08-05 12:56:11 +0000 (Wed, 05 Aug 2009)
New Revision: 11028
Modified:
Catalyst-Plugin-RunAfterRequest/trunk/Makefile.PL
Catalyst-Plugin-RunAfterRequest/trunk/lib/Catalyst/Plugin/RunAfterRequest.pm
Log:
Turn into a role and use cool 'stuff';
Modified: Catalyst-Plugin-RunAfterRequest/trunk/Makefile.PL
===================================================================
--- Catalyst-Plugin-RunAfterRequest/trunk/Makefile.PL 2009-08-04 00:22:27 UTC (rev 11027)
+++ Catalyst-Plugin-RunAfterRequest/trunk/Makefile.PL 2009-08-05 12:56:11 UTC (rev 11028)
@@ -12,7 +12,9 @@
requires 'Catalyst::Test';
requires 'Moose';
requires 'Moose::Role';
-requires 'MRO::Compat';
+requires 'MooseX::AttributeHelpers';
+requires 'MooseX::Types::Moose';
+requires 'namespace::autoclean';
test_requires 'Test::More';
test_requires 'Module::Find';
Modified: Catalyst-Plugin-RunAfterRequest/trunk/lib/Catalyst/Plugin/RunAfterRequest.pm
===================================================================
--- Catalyst-Plugin-RunAfterRequest/trunk/lib/Catalyst/Plugin/RunAfterRequest.pm 2009-08-04 00:22:27 UTC (rev 11027)
+++ Catalyst-Plugin-RunAfterRequest/trunk/lib/Catalyst/Plugin/RunAfterRequest.pm 2009-08-05 12:56:11 UTC (rev 11028)
@@ -1,25 +1,31 @@
package Catalyst::Plugin::RunAfterRequest;
-use strict;
-use warnings;
-use MRO::Compat;
+use Moose::Role;
+use MooseX::AttributeHelpers;
+use MooseX::Types::Moose qw/ArrayRef CodeRef/;
+use namespace::autoclean;
+
our $VERSION = '0.02';
-sub run_after_request {
- my $self = shift;
- push( @{ $self->{run_after_request} ||= [] }, @_ );
-}
+has _callbacks => (
+ metaclass => 'Collection::Array',
+ is => 'ro',
+ isa => ArrayRef[CodeRef],
+ default => sub { [] },
+ provides => {
+ push => 'run_after_request',
+ },
+);
-sub finalize {
+after finalize => sub {
my $self = shift;
- $self->next::method(@_);
$self->_run_code_after_request;
-}
+};
sub _run_code_after_request {
my $self = shift;
- $_->($self) for @{ $self->{run_after_request} || [] };
+ $_->($self) for @{ $self->_callbacks };
}
=head1 NAME
More information about the Catalyst-commits
mailing list