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   198445 use v5.28;
  18         76  
6 18     18   120 use strict;
  18         34  
  18         538  
7 18     18   88 use warnings;
  18         34  
  18         1303  
8              
9             our $VERSION = '0.33';
10              
11 18     18   539 use Iterator::Flex::Utils 'NEXT';
  18         40  
  18         1348  
12 18     18   104 use Scalar::Util;
  18         58  
  18         778  
13 18     18   837 use Role::Tiny;
  18         10823  
  18         117  
14 18     18   4599 use experimental 'signatures';
  18         62  
  18         115  
15              
16 18     18   3658 use namespace::clean;
  18         21294  
  18         157  
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31 97     97   166 sub _construct_next ( $class, $ipar, $ ) {
  97         185  
  97         157  
  97         179  
32              
33             # ensure we don't hold any strong references in the subroutine
34 97   33     312 my $sub = $ipar->{ +NEXT } // throw_failure( parameter => q{Missing 'next' parameter} );
35 97         259 Scalar::Util::weaken $ipar->{ +NEXT };
36 97         242 return $sub;
37             }
38              
39 554     554 1 2394 sub next ( $self ) { &{$self}() } ## no critic (BuiltinHomonyms)
  554         780  
  554         728  
  554         761  
  554         1776  
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__