blib/lib/Venus/Role/Unpackable.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 96.0% 24 / 25 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Venus/Role/Superable.pm ↑ Summary blib/lib/Venus/Core.pm »
1 package Venus::Role::Unpackable;
2  
3 1 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # IMPORTS
9  
10 1 ▶use Venus::Role 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # METHODS
13  
14 3 ▶sub unpack {
Subroutine unpack: called CC=1 SCAR=0.0
Pod documented
15 3 my ($self, @args) = @_;
16  
17 3 require Venus::Unpack;
18  
19 3 my $name = (caller(1))[3] =~ s/.*::(\w+)$/$1/gr;
20  
21 3 return Venus::Unpack->from($self)->name($name)->do('args', @args)->all;
22 }
23  
24 # EXPORTS
25  
26 1 ▶sub EXPORT {
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod undocumented
27 1 ['unpack']
28 }
29  
30 1 1;
31  
32  
33  
34 =head1 NAME
35  
36 Venus::Role::Unpackable - Unpackable Role
37  
38 =cut
39  
40 =head1 ABSTRACT
41  
42 Unpackable Role for Perl 5
43  
44 =cut
45  
46 =head1 SYNOPSIS
47  
48 package Example;
49  
50 use Venus::Class;
51  
52 with 'Venus::Role::Unpackable';
53  
54 sub execute {
55 return shift;
56 }
57  
58 package main;
59  
60 my $example = Example->new;
61  
62 # $example->unpack("hello", 123, 1.23)->signature(
63 # 'string', 'number', 'float',
64 # );
65  
66 =cut
67  
68 =head1 DESCRIPTION
69  
70 This package modifies the consuming package and provides methods for unpacking
71 and validating argument lists.
72  
73 =cut
74  
75 =head1 METHODS
76  
77 This package provides the following methods:
78  
79 =cut
80  
81 =head2 unpack
82  
83 unpack(any @args) (Venus::Unpack)
84  
85 The unpack method passes the arguments provided to L<Venus::Unpack> for
86 unpacking and validating arbitrary argument lists.
87  
88 I<Since C<2.01>>
89  
90 =over 4
91  
92 =item unpack example 1
93  
94 package main;
95  
96 my $example = Example->new;
97  
98 my $results = $example->unpack("hello", 123, 1.23)->signature(
99 'any',
100 );
101  
102 # ["hello", 123, 1.23]
103  
104 =back
105  
106 =over 4
107  
108 =item unpack example 2
109  
110 package main;
111  
112 my $example = Example->new;
113  
114 my $results = $example->unpack("hello", 123, 1.23)->signature(
115 'string',
116 'number | float',
117 );
118  
119 # ["hello", 123, 1.23]
120  
121 =back
122  
123 =over 4
124  
125 =item unpack example 3
126  
127 package main;
128  
129 my $example = Example->new;
130  
131 my $results = $example->unpack("hello", 123, 1.23)->signature(
132 'string',
133 'number',
134 'float',
135 );
136  
137 # ["hello", 123, 1.23]
138  
139 =back
140  
141 =cut
142  
143 =head1 AUTHORS
144  
145 Awncorp, C<awncorp@cpan.org>
146  
147 =cut
148  
149 =head1 LICENSE
150  
151 Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>.
152  
153 This program is free software, you can redistribute it and/or modify it under
154 the terms of the Apache license version 2.0.
155  
156 =cut
« blib/lib/Venus/Role/Superable.pm ↑ Summary blib/lib/Venus/Core.pm »