X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FAction.pm;h=0eb99424eed9222274f112c9504d47736aee0bb1;hp=e2e78b689156976a5c5a5341dbedcbaaf98b9fac;hb=05b47f2e6357bc7f1622e6b2cf730ad5bbeb993f;hpb=7b442de55a57592a0a9f09db2e85b135bb0c123f diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index e2e78b6..0eb9942 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -18,8 +18,9 @@ L subclasses. =cut use Moose; - +use Scalar::Util 'looks_like_number'; with 'MooseX::Emulate::Class::Accessor::Fast'; +use namespace::clean -except => 'meta'; has class => (is => 'rw'); has namespace => (is => 'rw'); @@ -28,8 +29,6 @@ has attributes => (is => 'rw'); has name => (is => 'rw'); has code => (is => 'rw'); -no Moose; - use overload ( # Stringify to reverse for debug output etc. @@ -38,6 +37,10 @@ use overload ( # Codulate to execute to invoke the encapsulated action coderef '&{}' => sub { my $self = shift; sub { $self->execute(@_); }; }, + # Which action takes precedence + 'cmp' => 'compare', + '<=>' => 'compare', + # Make general $stuff still work fallback => 1, @@ -70,6 +73,22 @@ sub match { return scalar( @{ $c->req->args } ) == $args; } +sub sort_order { + my $self = shift; + + my ($args) = @{ $self->attributes->{Args} || [] }; + + return $args if looks_like_number($args); + + return ~0; +} + +sub compare { + my ($a1, $a2) = @_; + + return $a1->sort_order <=> $a2->sort_order; +} + __PACKAGE__->meta->make_immutable; 1;