| 1 | package Chloro::Result::Field; | ||||||||||
| 2 | |||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 11 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 11 | our $VERSION = '0.07'; | |||||||||
| 8 | |||||||||||
| 9 | 11 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 11 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 11 | ▶ | use Chloro::Types qw( ArrayRef Item NonEmptyStr ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 11 | with 'Chloro::Role::Result'; | |||||||||
| 15 | |||||||||||
| 16 | 11 | has _errors => ( | |||||||||
| 17 | traits => ['Array'], | ||||||||||
| 18 | isa => ArrayRef ['Chloro::Error::Field'], | ||||||||||
| 19 | init_arg => 'errors', | ||||||||||
| 20 | required => 1, | ||||||||||
| 21 | handles => { | ||||||||||
| 22 | errors => 'elements', | ||||||||||
| 23 | is_valid => 'is_empty', | ||||||||||
| 24 | add_error => 'push', | ||||||||||
| 25 | }, | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | 11 | has param_names => ( | |||||||||
| 29 | is => 'ro', | ||||||||||
| 30 | isa => ArrayRef [NonEmptyStr], | ||||||||||
| 31 | required => 1, | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 11 | has field => ( | |||||||||
| 35 | is => 'ro', | ||||||||||
| 36 | isa => 'Chloro::Field', | ||||||||||
| 37 | required => 1, | ||||||||||
| 38 | ); | ||||||||||
| 39 | |||||||||||
| 40 | 11 | has value => ( | |||||||||
| 41 | is => 'ro', | ||||||||||
| 42 | isa => Item, | ||||||||||
| 43 | predicate => 'has_value', | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | 80 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 47 | 80 | my $self = shift; | |||||||||
| 48 | |||||||||||
| 49 | 80 | $_->_set_result($self) for $self->errors(); | |||||||||
| 50 | |||||||||||
| 51 | 80 | return; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | after add_error => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 55 | 0 | my $self = shift; | |||||||||
| 56 | 0 | my $error = shift; | |||||||||
| 57 | |||||||||||
| 58 | 0 | $error->_set_result($self); | |||||||||
| 59 | 11 | }; | |||||||||
| 60 | |||||||||||
| 61 | 37 | ▶ | sub key_value_pairs { | ||||||||
|
Subroutine
key_value_pairs: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 62 | 37 | my $self = shift; | |||||||||
| 63 | |||||||||||
| 64 | 37 | ▶ | return unless $self->has_value(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | |||||||||||
| 66 | 37 | return ( $self->field->name() => $self->value() ); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 11 | __PACKAGE__->meta()->make_immutable(); | |||||||||
| 70 | |||||||||||
| 71 | 11 | 1; | |||||||||
| 72 | |||||||||||
| 73 | # ABSTRACT: A result for a single field | ||||||||||
| 74 | |||||||||||
| 75 | __END__ | ||||||||||