| 1 | package MR::IProto::Response; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | MR::IProto::Response - response message | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Base class for all response messages. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | extends 'MR::IProto::Message'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 PUBLIC ATTRIBUTES | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =over | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =item request | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | Instance of L<MR::IProto::Request>. | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | has request => ( | |||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||
| 28 | isa => 'MR::IProto::Request', | ||||||||||||||||||||||||||||
| 29 | required => 1, | ||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =back | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 PUBLIC METHODS | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =over | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =item retry | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | Is request retry must be done. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub retry { | ||||||||||||||||||||||||||
|
Subroutine
retry: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 0 | return 0; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =back | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 PROTECTED METHODS | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =over | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =item BUILDARGS( %args | \%args | $data ) | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | If C<$data> is passed as argument then it unpacked and object is | ||||||||||||||||||||||||||||
| 57 | created based on information contained in it. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | See L<Mouse::Manual::Construction/BUILDARGS> for more information. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 64 | 0 | my ($orig, $class, %args) = @_; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | if( exists $args{data} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | my $parsed_args = $class->_parse_data($args{data}); | |||||||||||||||||||||||||||
| 67 | 0 | my $tail = delete $parsed_args->{data}; | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | warn "Not all data was parsed" if defined $tail && length $tail; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tail and length $tail
MC/DC0%0/2
defined $tail and length $tail
defined $tail
length $tail
Truth table0%0/3
A and B
A= defined $tailB= length $tail
| |||||||||||||||||||||||||||||
| 69 | 0 | return $class->$orig(%$parsed_args, %args); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | else { | ||||||||||||||||||||||||||||
| 72 | 0 | return $class->$orig(%args); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 1 | }; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =item _parse_data( $data ) | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | You B<must> implement this method in you subclass to unpack your object. | ||||||||||||||||||||||||||||
| 79 | Returns hashref of attributes which will be passed to constructor. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub _parse_data { | ||||||||||||||||||||||||||
|
Subroutine
_parse_data: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 84 | 0 | return { data => $_[1] }; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =back | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =cut | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 1 | ▶ | no Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 92 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 1 | 1; | |||||||||||||||||||||||||||