Simplify dispatcher guts to use hashes
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ActionContainer.pm
index 6b3f282..bb21c09 100644 (file)
@@ -12,6 +12,14 @@ use overload (
 
 );
 
+sub new {
+    my ( $class, $fields ) = @_;
+
+    $fields = { part => $fields, actions => {} } unless ref $fields;
+
+    $class->SUPER::new($fields);
+}
+
 =head1 NAME
 
 Catalyst::ActionContainer - Catalyst Action Container
@@ -39,6 +47,18 @@ sub get_action {
     return;
 }
 
+=head2 add_action($action, [ $name ])
+
+Adds an action, optionally providing a name to override $action->name
+
+=cut
+
+sub add_action {
+    my ( $self, $action, $name ) = @_;
+    my $name ||= $action->name;
+    $self->actions->{$name} = $action;
+}
+
 =head2 actions
 
 Accessor to the actions hashref, containing all actions in this container.