Fixed run-on sentence in COPYRIGHT and s/program/library/
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ActionContainer.pm
index bb1bbac..e8f71fe 100644 (file)
@@ -16,17 +16,24 @@ to represent the various dispatch points in your application.
 =cut
 
 use Moose;
+with 'MooseX::Emulate::Class::Accessor::Fast';
 
-has part => (is => 'rw', required => 1, lazy => 1, default => sub { {} });
+has part => (is => 'rw', required => 1);
 has actions => (is => 'rw', required => 1, lazy => 1, default => sub { {} });
 
-around new => sub {
-  my ($orig, $self, $params) = @_;
-  $orig->($self, (ref($params) ? $params :  { part => $params } ));
+around BUILDARGS => sub {
+    my ($next, $self, @args) = @_;
+    unshift @args, 'part' if scalar @args == 1 && !ref $args[0];
+    return $self->$next(@args);
 };
 
 no Moose;
 
+use overload (
+    # Stringify to path part for tree search
+    q{""} => sub { shift->part },
+);
+
 sub get_action {
     my ( $self, $name ) = @_;
     return $self->actions->{$name} if defined $self->actions->{$name};
@@ -80,7 +87,7 @@ Catalyst Contributors, see Catalyst.pm
 
 =head1 COPYRIGHT
 
-This program is free software, you can redistribute it and/or modify it under
+This library is free software. You can redistribute it and/or modify it under
 the same terms as Perl itself.
 
 =cut