| CatalystX-self documentation | Contained in the CatalystX-self distribution. |
CatalystX::self - A customized self for Catalyst controllers
Version 0.01
This is a very simple but handy module that shifts some of bits around from self to allow for an easier usage with (and with in) Catalyst controllers.
package MyApp::Foo;
use parent 'Catalyst::Controller';
use CatalystX::self;
sub bar : Local {
my ($some,$params) = args;
self->action_for('name');
catalyst->response->body('Hello World');
}
...
Simple! Since self and this module utilize Sub::Exporter you may rename the methods as you see fit. Here is an example that renames the args block word into some else and the catalyst block word into the more common and shorter 'c'.
package MyApp::LostShoes;
use parent 'Catalyst::Controller';
use CatalystX::self (
catalyst => { -as => 'c' },
args => { -as => 'gnargles' },
self => { -as => 'this' }
);
sub bar : Local {
this->{shoe} = gnargles;
c->res->body($this->{shoe});
}
...
You may also use the '-as' import renaming trick to do "aliases".
use CatalystX::self (
catalyst => { -as => 'c' },
'-all'
);
Now we have both 'catalyst' and 'c' block words.
See self in self
Returns properly shifted args in self for Catalyst controllers
Returns Catalyst object. Also known as the second argument in a Catalyst controller method.
Jason M. Mills, <jmmills at cpan.org>
Please report any bugs or feature requests to bug-catalystx-self at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-self. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc CatalystX::self
You can also look for information at:
Copyright 2008 Jason M. Mills, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| CatalystX-self documentation | Contained in the CatalystX-self distribution. |
package CatalystX::self; use warnings; use strict; use parent 'self'; use Sub::Exporter -setup => { exports => [qw/self catalyst args/], groups => { default => [-all] } };
our $VERSION = '0.01';
sub args { my @a = self::_args; return @a[2..$#a]; }
sub catalyst { return (self::_args)[1]; }
1; # End of CatalystX::self