| 1 | package Iterator::Flex::Role::Next::ClosedSelf; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # ABSTRACT: Role for closure iterator which closes over self | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 40 | ▶ | use v5.28; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 40 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 40 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 40 | our $VERSION = '0.33'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 40 | ▶ | use Ref::Util; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 40 | ▶ | use Scalar::Util; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 40 | ▶ | use Iterator::Flex::Utils qw( NEXT _SELF ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 40 | ▶ | use Role::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 40 | ▶ | use experimental 'signatures'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 40 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | ▶ | sub _construct_next ( $class, $ipar, $ ) { | |||||||||||||||||||
|
Subroutine
_construct_next: called CC=3 SCAR=11.4
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 288 | ▶ | my $sub = $ipar->{ +NEXT } // throw_failure( parameter => q{Missing 'next' parameter} ); | ||||||||||||||||||
|
Condition33%1/3
$ipar->{"next"} // throw_failure("parameter", "Missing 'next' parameter")
MC/DC0%0/2
$ipar->{"next"} // throw_failure("parameter", "Missing 'next' parameter")
$ipar->{"next"}
throw_failure("parameter", "Missing 'next' parameter")
Truth table33%1/3
A // B
A= $ipar->{"next"}B= throw_failure("parameter", "Missing 'next' parameter")
| |||||||||||||||||||||
| 30 | 288 | Scalar::Util::weaken $ipar->{ +NEXT }; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | throw_failure( parameter => q{Missing ability to set self} ) | ||||||||||||||||||||
| 33 | 288 | ▶ | unless exists $ipar->{ +_SELF }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 288 | my $ref = $ipar->{ +_SELF }; | |||||||||||||||||||
| 36 | 288 | $$ref = $sub; | |||||||||||||||||||
| 37 | 288 | Scalar::Util::weaken $$ref; | |||||||||||||||||||
| 38 | 288 | return $sub; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 1895 | ▶ | sub next ( $self ) { &{$self}() } ## no critic( BuiltinHomonyms ) | ||||||||||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 42 | 40 | *__next__ = \&next; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 40 | 1; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | # | ||||||||||||||||||||
| 47 | # This file is part of Iterator-Flex | ||||||||||||||||||||
| 48 | # | ||||||||||||||||||||
| 49 | # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. | ||||||||||||||||||||
| 50 | # | ||||||||||||||||||||
| 51 | # This is free software, licensed under: | ||||||||||||||||||||
| 52 | # | ||||||||||||||||||||
| 53 | # The GNU General Public License, Version 3, June 2007 | ||||||||||||||||||||
| 54 | # | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||