File Coverage

blib/lib/Hydrogen/CodeRef.pm
Criterion Covered Total %
statement 27 27 100.0
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod 4 4 100.0
total 42 43 97.6


line stmt bran cond sub pod time code
1             # This file was autogenerated.
2 3     3   225204 use 5.008001;
  3         16  
3 3     3   15 use strict;
  3         6  
  3         56  
4 3     3   13 use warnings;
  3         5  
  3         93  
5 3     3   15 no warnings qw( void once );
  3         8  
  3         79  
6 3     3   383 use Hydrogen ();
  3         5  
  3         221  
7              
8             package Hydrogen::CodeRef;
9              
10             our $AUTHORITY = 'cpan:TOBYINK';
11             our $VERSION = '0.018';
12              
13             =head1 NAME
14              
15             Hydrogen::CodeRef - a standard library for coderefs
16              
17             =head1 VERSION
18              
19             This documentation is for Hydrogen::CodeRef 0.018,
20             which is based on Sub::HandlesVia::HandlerLibrary::Code 0.046.
21              
22             =cut
23              
24             =head1 FUNCTIONS
25              
26             Each function expects a reference to a sub as its first argument.
27              
28             =cut
29              
30 3         27 use Exporter::Shiny qw(
31             execute
32             execute_list
33             execute_scalar
34             execute_void
35 3     3   37 );
  3         6  
36              
37             =head2 C<< execute( $coderef, @args ) >>
38              
39             Calls the coderef, passing it any arguments.
40              
41             =cut
42              
43             sub execute {
44 1     1 1 7117 my $__REF__ = \$_[0];
45              
46             package Hydrogen::CodeRef::__SANDBOX__;
47 1         8 $$__REF__->( @_[ 1 .. $#_ ] );
48             }
49              
50             =head2 C<< execute_list( $coderef, @args ) >>
51              
52             Calls the coderef, passing it any arguments, and forcing list context. If called in scalar context, returns an arrayref.
53              
54             =cut
55              
56             sub execute_list {
57 1     1 1 2824 my $__REF__ = \$_[0];
58              
59             package Hydrogen::CodeRef::__SANDBOX__;
60 1         6 my @shv_list = $$__REF__->( @_[ 1 .. $#_ ] );
61 1 50       8 wantarray ? @shv_list : \@shv_list;
62             }
63              
64             =head2 C<< execute_scalar( $coderef, @args ) >>
65              
66             Calls the coderef, passing it any arguments, and forcing scalar context.
67              
68             =cut
69              
70             sub execute_scalar {
71 1     1 1 3518 my $__REF__ = \$_[0];
72              
73             package Hydrogen::CodeRef::__SANDBOX__;
74 1         6 scalar( $$__REF__->( @_[ 1 .. $#_ ] ) );
75             }
76              
77             =head2 C<< execute_void( $coderef, @args ) >>
78              
79             Calls the coderef, passing it any arguments, and forcing void context. Returns undef.
80              
81             =cut
82              
83             sub execute_void {
84 1     1 1 3057 my $__REF__ = \$_[0];
85              
86             package Hydrogen::CodeRef::__SANDBOX__;
87 1         7 $$__REF__->( @_[ 1 .. $#_ ] );
88 1         5 undef;
89             }
90              
91             1;
92              
93             =head1 EXPORT
94              
95             No functions are exported by this module by default. To import them all (this is usually a bad idea), use:
96              
97             use Hydrogen::CodeRef -all;
98              
99             To import a particular function, use:
100              
101             use Hydrogen::CodeRef 'execute_scalar';
102              
103             To rename functions:
104              
105             use Hydrogen::CodeRef 'execute_scalar' => { -as => 'myfunc' };
106              
107             On Perl 5.37.2+, you can import lexically:
108              
109             use Hydrogen::CodeRef -lexical, 'execute_scalar';
110              
111             See L for more hints on importing.
112              
113             =head1 BUGS
114              
115             Please report any bugs to
116             L.
117              
118             =head1 SEE ALSO
119              
120             L,
121             L,
122             L,
123             L,
124             L,
125             L.
126              
127             =head1 AUTHOR
128              
129             Toby Inkster Etobyink@cpan.orgE.
130              
131             =head1 COPYRIGHT AND LICENCE
132              
133             This software is copyright (c) 2022 by Toby Inkster.
134              
135             This is free software; you can redistribute it and/or modify it under
136             the same terms as the Perl 5 programming language system itself.
137              
138             =head1 DISCLAIMER OF WARRANTIES
139              
140             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
141             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
142             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
143