File Coverage

blib/lib/Iterator/Flex/Role/Next/Closure.pm
Criterion Covered Total %
statement 35 35 100.0
branch n/a
condition 1 3 33.3
subroutine 10 10 100.0
pod 1 1 100.0
total 47 49 95.9


line stmt bran cond sub pod time code
1             package Iterator::Flex::Role::Next::Closure;
2              
3             # ABSTRACT: Construct a next() method for iterators without closed over $self
4              
5 18     18   185002 use v5.28;
  18         53  
6 18     18   68 use strict;
  18         37  
  18         336  
7 18     18   59 use warnings;
  18         23  
  18         1032  
8              
9             our $VERSION = '0.34';
10              
11 18     18   470 use Iterator::Flex::Utils 'NEXT', 'throw_failure';
  18         33  
  18         915  
12 18     18   73 use Scalar::Util;
  18         33  
  18         466  
13 18     18   442 use Role::Tiny;
  18         4518  
  18         88  
14 18     18   3280 use experimental 'signatures';
  18         61  
  18         112  
15              
16 18     18   2470 use namespace::clean;
  18         11185  
  18         104  
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31 99     99   117 sub _construct_next ( $class, $ipar, $ ) {
  99         115  
  99         99  
  99         104  
32              
33             # ensure we don't hold any strong references in the subroutine
34 99   33     214 my $sub = $ipar->{ +NEXT } // throw_failure( parameter => q{Missing 'next' parameter} );
35 99         171 Scalar::Util::weaken $ipar->{ +NEXT };
36 99         191 return $sub;
37             }
38              
39 554     554 1 1548 sub next ( $self ) { &{$self}() } ## no critic (BuiltinHomonyms)
  554         536  
  554         494  
  554         529  
  554         1203  
40             *__next__ = \&next;
41              
42             1;
43              
44             #
45             # This file is part of Iterator-Flex
46             #
47             # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
48             #
49             # This is free software, licensed under:
50             #
51             # The GNU General Public License, Version 3, June 2007
52             #
53              
54             __END__