« lib/HTML/FormFu/Role/FormAndElementMethods.pm
↑ Summary
lib/HTML/FormFu/Role/ContainsElementsSharedWithField.pm »
| 1 | 456 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package HTML::FormFu::Exception::Input; | ||||||||||||||||||
| 4 | # ABSTRACT: Input exception | ||||||||||||||||||
| 5 | 456 | $HTML::FormFu::Exception::Input::VERSION = '2.09'; | |||||||||||||||||
| 6 | 456 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 456 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 456 | extends 'HTML::FormFu::Exception'; | |||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | 456 | ▶ | use HTML::FormFu::Attribute qw( mk_attrs ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | 456 | ▶ | use HTML::FormFu::Util qw( append_xml_attribute literal xml_escape _merge_hashes ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 456 | has processor => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||
| 14 | 456 | has forced => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | 456 | __PACKAGE__->mk_attrs(qw( attributes )); | |||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | 237 | ▶ | sub BUILD { | ||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 19 | 237 | my ( $self ) = @_; | |||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 237 | $self->attributes( {} ); | |||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | 237 | return; | |||||||||||||||||
| 24 | } | ||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | 302 | ▶ | sub name { | ||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 27 | 302 | my ($self) = @_; | |||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | 302 | return $self->parent->name; | |||||||||||||||||
| 30 | } | ||||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 58 | ▶ | sub message { | ||||||||||||||||
|
Subroutine
message: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||
| 33 | 58 | my ( $self, $message ) = @_; | |||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | 58 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 36 | 0 | return $self->{message} = $message; | |||||||||||||||||
| 37 | } | ||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 58 | ▶ | return $self->{message} if defined $self->{message}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 47 | ▶ | return $self->processor->message if defined $self->processor->message; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | 40 | ▶ | my %string = ( | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 44 | f => defined $self->form->id ? $self->form->id : '', | ||||||||||||||||||
| 45 | n => defined $self->name ? $self->name : '', | ||||||||||||||||||
| 46 | t => defined $self->type ? lc( $self->type ) : '', | ||||||||||||||||||
| 47 | s => $self->stage, | ||||||||||||||||||
| 48 | ); | ||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | 40 | $string{t} =~ s/::/_/g; | |||||||||||||||||
| 51 | 40 | $string{t} =~ s/\+//; | |||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | 40 | my $error_message = $self->parent->auto_error_message; | |||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | 40 | $error_message =~ s/%([fnts])/$string{$1}/g; | |||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | 40 | $error_message = $self->form->localize( $error_message, | |||||||||||||||||
| 58 | $self->processor->localize_args ); | ||||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | 40 | return $self->{message} = $error_message; | |||||||||||||||||
| 61 | } | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | 147 | ▶ | sub type { | ||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 64 | 147 | my ($self) = @_; | |||||||||||||||||
| 65 | |||||||||||||||||||
| 66 | 147 | return $self->processor->type; | |||||||||||||||||
| 67 | } | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | 1 | ▶ | sub clone { | ||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 70 | 1 | my ($self) = @_; | |||||||||||||||||
| 71 | |||||||||||||||||||
| 72 | 1 | my %new = %$self; | |||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | 1 | return bless \%new, ref $self; | |||||||||||||||||
| 75 | } | ||||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | 54 | ▶ | around render_data_non_recursive => sub { | ||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||
| 78 | 54 | my ( $orig, $self, $args ) = @_; | |||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | 54 | ▶ | my $render = $self->$orig( | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 81 | { processor => $self->processor, | ||||||||||||||||||
| 82 | forced => $self->forced, | ||||||||||||||||||
| 83 | name => $self->name, | ||||||||||||||||||
| 84 | message => $self->message, | ||||||||||||||||||
| 85 | type => $self->type, | ||||||||||||||||||
| 86 | $args ? %$args : (), | ||||||||||||||||||
| 87 | } ); | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | 54 | $self->_render_attributes($render); | |||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | 54 | return $render; | |||||||||||||||||
| 92 | 456 | }; | |||||||||||||||||
| 93 | |||||||||||||||||||
| 94 | 54 | ▶ | sub _render_attributes { | ||||||||||||||||
|
Subroutine
_render_attributes: called CC=5 SCAR=16.2
| |||||||||||||||||||
| 95 | 54 | my ( $self, $render ) = @_; | |||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | 54 | my $attrs = xml_escape( | |||||||||||||||||
| 98 | $self->parent->error_attributes, | ||||||||||||||||||
| 99 | $self->attributes, | ||||||||||||||||||
| 100 | ); | ||||||||||||||||||
| 101 | |||||||||||||||||||
| 102 | 54 | my $auto_error_class = $self->parent->auto_error_class; | |||||||||||||||||
| 103 | |||||||||||||||||||
| 104 | 54 | ▶ | if ( defined $auto_error_class ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 105 | 2 | ▶ | my %string = ( | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 106 | f => defined $self->form->id ? $self->form->id : '', | ||||||||||||||||||
| 107 | n => defined $self->name ? $self->name : '', | ||||||||||||||||||
| 108 | t => defined $self->type ? lc( $self->type ) : '', | ||||||||||||||||||
| 109 | s => $self->stage, | ||||||||||||||||||
| 110 | ); | ||||||||||||||||||
| 111 | |||||||||||||||||||
| 112 | 2 | $string{t} =~ s/::/_/g; | |||||||||||||||||
| 113 | 2 | $string{t} =~ s/\+//; | |||||||||||||||||
| 114 | |||||||||||||||||||
| 115 | 2 | $auto_error_class =~ s/%([fnts])/$string{$1}/g; | |||||||||||||||||
| 116 | |||||||||||||||||||
| 117 | 2 | append_xml_attribute( $attrs, 'class', $auto_error_class ); | |||||||||||||||||
| 118 | } | ||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | 54 | $render->{attributes} = $attrs; | |||||||||||||||||
| 121 | } | ||||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | 456 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | 456 | 1; | |||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | __END__ | ||||||||||||||||||