| 1 | 404 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package HTML::FormFu::Exception::Input; | ||||||||||||||||||
| 4 | 404 | $HTML::FormFu::Exception::Input::VERSION = '2.06'; | |||||||||||||||||
| 5 | 404 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | 404 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 404 | extends 'HTML::FormFu::Exception'; | |||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | 404 | ▶ | use HTML::FormFu::Attribute qw( mk_attrs ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | 404 | ▶ | use HTML::FormFu::Util qw( append_xml_attribute literal xml_escape ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | 404 | has processor => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||
| 13 | 404 | has forced => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | 404 | __PACKAGE__->mk_attrs(qw( attributes )); | |||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | sub BUILD { | ||||||||||||||||||
| 18 | 198 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | 198 | $self->attributes( {} ); | |||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 198 | return; | |||||||||||||||||
| 23 | } | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | sub name { | ||||||||||||||||||
| 26 | 298 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | 298 | return $self->parent->name; | |||||||||||||||||
| 29 | } | ||||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | sub message { | ||||||||||||||||||
| 32 | 54 | ▶ | my ( $self, $message ) = @_; | ||||||||||||||||
|
Subroutine
message: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 54 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 35 | 0 | return $self->{message} = $message; | |||||||||||||||||
| 36 | } | ||||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | 54 | ▶ | return $self->{message} if defined $self->{message}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | 43 | ▶ | return $self->processor->message if defined $self->processor->message; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 41 | |||||||||||||||||||
| 42 | 40 | ▶ | my %string = ( | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 43 | f => defined $self->form->id ? $self->form->id : '', | ||||||||||||||||||
| 44 | n => defined $self->name ? $self->name : '', | ||||||||||||||||||
| 45 | t => defined $self->type ? lc( $self->type ) : '', | ||||||||||||||||||
| 46 | s => $self->stage, | ||||||||||||||||||
| 47 | ); | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | 40 | $string{t} =~ s/::/_/g; | |||||||||||||||||
| 50 | 40 | $string{t} =~ s/\+//; | |||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | 40 | my $error_message = $self->parent->auto_error_message; | |||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | 40 | $error_message =~ s/%([fnts])/$string{$1}/g; | |||||||||||||||||
| 55 | |||||||||||||||||||
| 56 | 40 | $error_message = $self->form->localize( $error_message, | |||||||||||||||||
| 57 | $self->processor->localize_args ); | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | 40 | return $self->{message} = $error_message; | |||||||||||||||||
| 60 | } | ||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | sub type { | ||||||||||||||||||
| 63 | 143 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | 143 | return $self->processor->type; | |||||||||||||||||
| 66 | } | ||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | sub clone { | ||||||||||||||||||
| 69 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | 1 | my %new = %$self; | |||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | 1 | return bless \%new, ref $self; | |||||||||||||||||
| 74 | } | ||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | around render_data_non_recursive => sub { | ||||||||||||||||||
| 77 | 50 | ▶ | my ( $orig, $self, $args ) = @_; | ||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||
| 78 | |||||||||||||||||||
| 79 | 50 | ▶ | my $render = $self->$orig( | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 80 | { processor => $self->processor, | ||||||||||||||||||
| 81 | forced => $self->forced, | ||||||||||||||||||
| 82 | name => $self->name, | ||||||||||||||||||
| 83 | message => $self->message, | ||||||||||||||||||
| 84 | type => $self->type, | ||||||||||||||||||
| 85 | $args ? %$args : (), | ||||||||||||||||||
| 86 | } ); | ||||||||||||||||||
| 87 | |||||||||||||||||||
| 88 | 50 | $self->_render_attributes($render); | |||||||||||||||||
| 89 | |||||||||||||||||||
| 90 | 50 | return $render; | |||||||||||||||||
| 91 | 404 | }; | |||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | sub _render_attributes { | ||||||||||||||||||
| 94 | 50 | ▶ | my ( $self, $render ) = @_; | ||||||||||||||||
|
Subroutine
_render_attributes: called CC=5 SCAR=16.2
| |||||||||||||||||||
| 95 | |||||||||||||||||||
| 96 | 50 | my $attrs = xml_escape( $self->attributes ); | |||||||||||||||||
| 97 | |||||||||||||||||||
| 98 | 50 | my $auto_error_class = $self->parent->auto_error_class; | |||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | 50 | ▶ | if ( defined $auto_error_class ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 101 | 2 | ▶ | my %string = ( | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 102 | f => defined $self->form->id ? $self->form->id : '', | ||||||||||||||||||
| 103 | n => defined $self->name ? $self->name : '', | ||||||||||||||||||
| 104 | t => defined $self->type ? lc( $self->type ) : '', | ||||||||||||||||||
| 105 | s => $self->stage, | ||||||||||||||||||
| 106 | ); | ||||||||||||||||||
| 107 | |||||||||||||||||||
| 108 | 2 | $string{t} =~ s/::/_/g; | |||||||||||||||||
| 109 | 2 | $string{t} =~ s/\+//; | |||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | 2 | $auto_error_class =~ s/%([fnts])/$string{$1}/g; | |||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | 2 | append_xml_attribute( $attrs, 'class', $auto_error_class ); | |||||||||||||||||
| 114 | } | ||||||||||||||||||
| 115 | |||||||||||||||||||
| 116 | 50 | $render->{attributes} = $attrs; | |||||||||||||||||
| 117 | } | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | 404 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||
| 120 | |||||||||||||||||||
| 121 | 404 | 1; | |||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | __END__ | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | =pod | ||||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | =encoding UTF-8 | ||||||||||||||||||
| 128 | |||||||||||||||||||
| 129 | =head1 NAME | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | HTML::FormFu::Exception::Input | ||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | =head1 VERSION | ||||||||||||||||||
| 134 | |||||||||||||||||||
| 135 | version 2.06 | ||||||||||||||||||
| 136 | |||||||||||||||||||
| 137 | =head1 AUTHOR | ||||||||||||||||||
| 138 | |||||||||||||||||||
| 139 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||
| 142 | |||||||||||||||||||
| 143 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||
| 144 | |||||||||||||||||||
| 145 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 146 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||
| 147 | |||||||||||||||||||
| 148 | =cut | ||||||||||||||||||