File Coverage

blib/lib/Form/Factory/Feature.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Form::Factory::Feature;
2             $Form::Factory::Feature::VERSION = '0.022';
3 1     1   443 use Moose::Role;
  1         1  
  1         6  
4              
5 1     1   3722 use Scalar::Util qw( blessed );
  1         1  
  1         167  
6              
7             # ABSTRACT: Interface for objects that modify how actions work
8              
9              
10             has name => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1,
14             lazy => 1,
15             default => sub {
16             my $self = shift;
17             my $class_name = blessed $self;
18             unless ($class_name =~ s/^Form::Factory::Feature::Control:://) {
19             $class_name =~ s/^Form::Factory::Feature:://;
20             }
21 1     1   542 $class_name =~ s/(\p{Lu})/_\l$1/g;
  1         9  
  1         11  
22             $class_name =~ s/\W+/_/g;
23             $class_name =~ s/_+/_/g;
24             $class_name =~ s/^_//;
25             return lc $class_name;
26             },
27             );
28              
29              
30             has action => (
31             is => 'ro',
32             does => 'Form::Factory::Action',
33             required => 1,
34             weak_ref => 1,
35             );
36              
37              
38             has result => (
39             is => 'ro',
40             isa => 'Form::Factory::Result::Single',
41             required => 1,
42             lazy => 1,
43             default => sub { Form::Factory::Result::Single->new },
44             );
45              
46             1;
47              
48             __END__
49              
50             =pod
51              
52             =encoding UTF-8
53              
54             =head1 NAME
55              
56             Form::Factory::Feature - Interface for objects that modify how actions work
57              
58             =head1 VERSION
59              
60             version 0.022
61              
62             =head1 SYNOPSIS
63              
64             package MyApp::Feature::Foo;
65             use Moose;
66              
67             with qw( Form::Factory::Feature );
68              
69             package Form::Factory:;Feature::Custom::Foo;
70             sub register_implementation { 'MyApp::Feature::Foo' }
71              
72             =head1 DESCRIPTION
73              
74             A feature modifies what the form does during processing.
75              
76             =head1 ATTRIBUTES
77              
78             =head2 name
79              
80             The short name of the feature. This is automatically built from the feature's class name.
81              
82             =head2 action
83              
84             The action this feature has been attached to.
85              
86             =head2 result
87              
88             This is the L<Form::Factory::Result::Single> recording the success or failure of the parts of this feature.
89              
90             =head1 AUTHOR
91              
92             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is copyright (c) 2015 by Qubling Software LLC.
97              
98             This is free software; you can redistribute it and/or modify it under
99             the same terms as the Perl 5 programming language system itself.
100              
101             =cut