Skip to content

Instantly share code, notes, and snippets.

View jjn1056's full-sized avatar

John Napiorkowski jjn1056

View GitHub Profile
if ($ENV{MOD_PERL}) {
# FIXME - Immutable
$class->meta->add_method(handler => sub {
my $r = shift;
my $app = $class->psgi_app;
use Plack::Handler::Apache2;
Plack::Handler::Apache2->call_app($r, $app);
});
}
In my Catalyst.pm:
if ($ENV{MOD_PERL}) {
use Catalyst::Engine::Loader;
my $apache = Catalyst::Engine::Loader->auto;
# FIXME - Immutable
$class->meta->add_method(handler => sub {
my $r = shift;
my $app = $class->psgi_app;
$apache->call_app($r, $app);
use MooseX::Declare;
role MyParameterizableRole(Str :$prefix = "test")
{
requires 'mymethod';
around mymethod($aaa) {
return $prefix .":". $self->$orig($aaa);
}
}
John-Napiorkowski-MacBook-Pro:ParameterizedRolesAndMethodTraits johnn$ perl -e 'use Scalar::Util qw(weaken isweak); my $a = \"sss"; my $b = weaken($a); warn isweak($a) ? 1:0; warn isweak($b) ? 1:0 ;'
1 at -e line 1.
0 at -e line 1.
## tried
use MooseX::Declare;
class LoggedMethodsParameterizableRole
with HasLogging(target_method=>'my_method')
{
method my_method(Str $name, Int $age) {
return "Hi $name, you are $age years old";
}
}
package MyApp::Controller::User;
use Moose;
extends 'Catalyst::Controller';
with 'CatalystX::TraitFor::Controller::AllowActionRoleParameters
sub myaction
:Action
:Does('MyActionRoleWithParams')
:MyActionRoleWithParams('param1=>10,param2=>20')
John-Napiorkowski-MacBook-Pro:~ johnn$ diff -r -x .DS_Store -x.git ~/Desktop/catalyst-controller-actionrole/ ~/Desktop/bobtfish/catalyst-controller-actionrole/
diff -r -x .DS_Store -x.git /Users/johnn/Desktop/catalyst-controller-actionrole/Changes /Users/johnn/Desktop/bobtfish/catalyst-controller-actionrole/Changes
1,2d0
< 0.15 TBD
< * Added action_args support and Does parameterization
diff -r -x .DS_Store -x.git /Users/johnn/Desktop/catalyst-controller-actionrole/lib/Catalyst/Controller/ActionRole.pm /Users/johnn/Desktop/bobtfish/catalyst-controller-actionrole/lib/Catalyst/Controller/ActionRole.pm
40c40
< package MyApp::Controller::Bar;
---
> package MyApp::Controller::Bar
If you are not a developer and just want to run the app (don't care
about git, perl lib, etc) you can actually just install and run the
app very easily. Change to a directory under your control (such as
$HOME/Desktop on a Mac or most linux distros) and run the following
from the shell. If you are trying this after doing the above,
remember to exit your local-lib enabled shell first :)
curl -L cpanmin.us | perl - -L shutterstock-example-0_07
http://github.com/downloads/jjn1056/Shutterstock-Example/Shutterstock-Example-0.07.tar.gz
sub myaction
:Action
:Does('MyCustomActionRole')
:Mycustomattribute(1)
action myaction
with MyCustomActionRole(mycustomattribute=>1)
use Benchmark ':hireswallclock', qw(:all);
use MooseX::Types::Moose qw(Str Int ArrayRef HashRef);
use MooseX::Types::Structured qw(Tuple Dict);
use Moose::Util::TypeConstraints;
my $assigned_int;
my $assigned_array;
my $assigned_hash;
my $assigned_tuple;