File Coverage

blib/lib/Net/Easypost/PostOnBuild.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition 1 3 33.3
subroutine 3 3 100.0
pod 2 2 100.0
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Net::Easypost::PostOnBuild;
2             $Net::Easypost::PostOnBuild::VERSION = '0.21';
3 6     6   43263 use Moo::Role;
  6         17  
  6         36  
4              
5       39 1   sub BUILD {}
6             after 'BUILD' => sub {
7             my $self = shift;
8              
9             my $resp = $self->requester->post(
10             $self->operation,
11             $self->serialize,
12             );
13             $self->_set_id( $resp->{id} );
14             };
15              
16             sub serialize {
17 7     7 1 26 my ($self, $attrs) = @_;
18 7   33     87 $attrs //= $self->fieldnames;
19              
20             # want a hashref of e.g., role[field1] => foo from all defined attributes
21             return {
22 25         278 map { $self->role . "[$_]" => $self->$_ }
23 7         23 grep { defined $self->$_ } @$attrs
  38         301  
24             };
25             }
26              
27             1;
28              
29             __END__