« blib/lib/Iterator/Flex/Role/Next/ClosedSelf.pm
↑ Summary
blib/lib/Iterator/Flex/Role/Exhaustion/PassthroughThrow.pm »
| 1 | package Iterator::Flex::Role::Freeze; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Role to add serialization capability to an Iterator::Flex::Base | ||||||||||
| 4 | |||||||||||
| 5 | 27 | ▶ | use v5.28; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 27 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 27 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 27 | our $VERSION = '0.33'; | |||||||||
| 10 | |||||||||||
| 11 | 27 | ▶ | use List::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | use Iterator::Flex::Utils | ||||||||||
| 14 | 27 | ▶ | qw( :default REG_ITERATOR REG_ITER__DEPENDS REG_ITER_FREEZE throw_failure ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 27 | ▶ | use Iterator::Flex::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 27 | ▶ | use Role::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 27 | ▶ | use experimental 'signatures'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 27 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | ▶ | sub freeze ( $obj ) { | |||||||||
|
Subroutine
freeze: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 31 | |||||||||||
| 32 | 40 | my $ipar = $REGISTRY{ refaddr $obj }[REG_ITERATOR]; | |||||||||
| 33 | |||||||||||
| 34 | 40 | my @freeze; | |||||||||
| 35 | |||||||||||
| 36 | 40 | ▶ | if ( defined $ipar->[REG_ITER__DEPENDS] ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | # first check if dependencies can freeze. | ||||||||||
| 39 | 6 | ▶ | my $cant = List::Util::first { !$_->can( 'freeze' ) } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 40 | 4 | @{ $ipar->[REG_ITER__DEPENDS] }; | |||||||||
| 41 | 4 | ▶ | throw_failure( parameter => "dependency: @{[ $cant->_name ]} is not serializeable" ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | if $cant; | ||||||||||
| 43 | |||||||||||
| 44 | # now freeze them | ||||||||||
| 45 | 4 | @freeze = map $_->freeze, @{ $ipar->[REG_ITER__DEPENDS] }; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 40 | push @freeze, $ipar->[REG_ITER_FREEZE]->( $obj ), $obj->is_exhausted; | |||||||||
| 49 | |||||||||||
| 50 | 40 | return \@freeze; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 27 | requires 'is_exhausted'; | |||||||||
| 54 | |||||||||||
| 55 | 27 | 1; | |||||||||
| 56 | |||||||||||
| 57 | # | ||||||||||
| 58 | # This file is part of Iterator-Flex | ||||||||||
| 59 | # | ||||||||||
| 60 | # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. | ||||||||||
| 61 | # | ||||||||||
| 62 | # This is free software, licensed under: | ||||||||||
| 63 | # | ||||||||||
| 64 | # The GNU General Public License, Version 3, June 2007 | ||||||||||
| 65 | # | ||||||||||
| 66 | |||||||||||
| 67 | __END__ | ||||||||||