blib/lib/UR/Role/MethodModifier/After.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 48 SCAR 40.3
CC
7
Cov
0%
create_wrapper_sub
56.0
type
2.0
BEGIN
2.0
CRAP 56.0
1 package UR::Role::MethodModifier::After;
2 use strict;
3 use warnings;
4  
5 our $VERSION = "0.46"; # UR $VERSION;
6  
7 use UR;
8  
9 UR::Object::Type->define(
10 class_name => 'UR::Role::MethodModifier::After',
11 is => 'UR::Role::MethodModifier',
12 );
13  
14 sub type { 'after' }
15  
16 sub create_wrapper_sub {
17 my($self, $original_sub) = @_;
18  
19 my $after = $self->code;
20 return sub {
21 my @rv;
22 my $wantarray = wantarray;
23 if ($wantarray) {
24 @rv = $original_sub->(@_);
25 } elsif (defined $wantarray) {
26 $rv[0] = $original_sub->(@_);
27 } else {
28 $original_sub->(@_);
29 }
30  
31 if ($wantarray) {
32 () = $after->(\@rv, @_);
33 } elsif (defined $wantarray) {
34 my $i = $after->($rv[0], @_);
35 } else {
36 $after->(undef, @_);
37 }
38  
39 if ($wantarray) {
40 return @rv;
41 } elsif (defined $wantarray) {
42 return $rv[0];
43 } else {
44 return;
45 }
46 };
47 }
48  
49 1;