blib/lib/Iterator/Flex/Role/Wrap/Self.pm

filter: Statementstmt 75.7% 25 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod n/a totaltotal 76.7% 33 / 43 CC 1 SCAR 1.8
CC
1
Cov
76%
_construct_next
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Iterator/Flex/Role/Next/Closure.pm ↑ Summary blib/lib/Iterator/Flex/Role/Exhaustion/Throw.pm »
1 package Iterator::Flex::Role::Wrap::Self;
2  
3 # ABSTRACT: Construct a next() method for a coderef which expects to be passed an object ref
4  
5 # is this actually used?
6  
7 1 ▶use v5.28;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = '0.33';
12  
13 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Iterator::Flex::Utils 'NEXT';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 ▶sub _construct_next ( $, $ipar, $ ) {
Subroutine _construct_next: not called CC=1 SCAR=6.9
22  
23 # ensure we don't hold any strong references in the subroutine
24 0 my $next = $ipar->{ +NEXT };
25 0 Scalar::Util::weaken $next;
26  
27 0 my $sub;
28 0 ▶ $sub = sub { $next->( $sub ) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
29  
30 # create a second reference to the subroutine before we weaken $sub,
31 # otherwise $sub will lose its contents, as it would be the only
32 # reference.
33 0 my $rsub = $sub;
34 0 Scalar::Util::weaken( $sub );
35 0 return $rsub;
36 }
37  
38 1 1;
39  
40 #
41 # This file is part of Iterator-Flex
42 #
43 # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
44 #
45 # This is free software, licensed under:
46 #
47 # The GNU General Public License, Version 3, June 2007
48 #
49  
50 __END__
« blib/lib/Iterator/Flex/Role/Next/Closure.pm ↑ Summary blib/lib/Iterator/Flex/Role/Exhaustion/Throw.pm »