1 package Reaction::UI::Controller::Role::Action::Object;
3 use Moose::Role -traits => 'MethodAttributes';
5 requires 'get_collection';
7 sub object :Action :CaptureArgs(1) {
8 my ($self, $c, $key) = @_;
9 if( my $object = $self->get_collection($c)->find($key) ){
10 $c->stash(object => $object);
23 Reaction::UI::Controller::Role::Action::Object
27 Provides an C<object> action, which attempts to find an item in a collection
28 and store it in the stash.
32 package MyApp::Controller::Foo;
34 use base 'Reaction::Controller';
38 'Reaction::UI::Controller::Role::GetCollection',
39 'Reaction::UI::Controller::Role::Action::Simple',
40 'Reaction::UI::Controller::Role::Action::Object',
43 __PACKAGE__->config( action => {
44 object => { Chained => 'base', PathPart => 'id' },
45 foo_action => { Chained => 'object' },
48 sub base :Chained('/base') :CaptureArgs(0) {
52 sub foo_action :Args(0){
54 $c->stash->{object}; #object is here....
57 =head1 REQUIRED METHODS
59 The following methods must be provided by the consuming class:
63 =item C<get_collection>
71 Chain link, captures one argument. Attempts to find a single object by passing
72 the captured argument to the C<find> method of the collection returned by
73 C<get_collection>. If the object is found it is stored in the stash under the
80 =item L<Reaction::UI::Controller>
82 =item L<Reaction::UI::Controller::Role::GetCollection>
84 =item L<Reaction::UI::Controller::Role::Action::Simple>
86 =item L<Reaction::UI::Controller::Role::Action::List>
88 =item L<Reaction::UI::Controller::Role::Action::View>
90 =item L<Reaction::UI::Controller::Role::Action::Create>
92 =item L<Reaction::UI::Controller::Role::Action::Update>
94 =item L<Reaction::UI::Controller::Role::Action::Delete>
96 =item L<Reaction::UI::Controller::Role::Action::DeleteAll>
102 See L<Reaction::Class> for authors.
106 See L<Reaction::Class> for the license.