blib/lib/CatalystX/Resource/TraitFor/Controller/Resource/Create.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 20 CC 1 SCAR 6.9
CC
1
Cov
0%
create
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package CatalystX::Resource::TraitFor::Controller::Resource::Create;
2 $CatalystX::Resource::TraitFor::Controller::Resource::Create::VERSION = '0.009_002';
3 use MooseX::MethodAttributes::Role;
4 use namespace::autoclean;
5  
6 # ABSTRACT: a create action for your resource
7  
8 requires qw/
9 resultset_key
10 resource_key
11 form
12 /;
13  
14  
15 has 'activate_fields_create' => (
16 is => 'ro',
17 isa => 'ArrayRef',
18 default => sub { [] },
19 );
20  
21  
22 sub create : Method('GET') Method('POST') Chained('base') PathPart('create') Args(0) {
23 my ( $self, $c ) = @_;
24 my $resource = $c->stash->{ $self->resultset_key }->new_result( {} );
25 $c->stash(
26 $self->resource_key => $resource,
27 set_create_msg => 1,
28 );
29 $self->form( $c, $self->activate_fields_create );
30 }
31  
32 1;
33  
34 __END__
35  
36 =pod
37  
38 =encoding UTF-8
39  
40 =head1 NAME
41  
42 CatalystX::Resource::TraitFor::Controller::Resource::Create - a create action for your resource
43  
44 =head1 VERSION
45  
46 version 0.009_002
47  
48 =head1 ATTRIBUTES
49  
50 =head2 activate_fields_create
51  
52 (default = []).
53 arrayref of form fields to activate in the create form
54 (e.g. ['password', 'password_confirm'], default = [])
55 Can be overriden with $c->stash->{activate_form_fields}
56  
57 Example: You only want admins to be able to change a field.
58 Disable field by default in HTML::FormHandler.
59  
60 =head1 ACTIONS
61  
62 =head2 create
63  
64 create a resource
65  
66 =head1 AUTHOR
67  
68 David Schmidt <davewood@cpan.org>
69  
70 =head1 COPYRIGHT AND LICENSE
71  
72 This software is copyright (c) 2011 by David Schmidt.
73  
74 This is free software; you can redistribute it and/or modify it under
75 the same terms as the Perl 5 programming language system itself.
76  
77 =cut