Transfigure/Node.pm untested

filter: Statementstmt 0.0% 0 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 17 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Data::Transfigure::Node 1.03;
2 use v5.26;
3 use warnings;
4  
5 # ABSTRACT: the root role which all Data::Transfigure transfigurators must implement
6  
7 =encoding UTF-8
8
9 =head1 NAME
10
11 Data::Transfigure::Node - the root role which all Data::Transfigure transfigurators
12 must implement
13  
14 =head1 DESCRIPTION
15  
16 C<Data::Transfigure::Node> must be implemented by all transfigurators used by
17 L<Data::Transfigure>
18  
19 =cut
20  
21 use Object::Pad;
22  
23 role Data::Transfigure::Node {
24  
25 =head1 FIELDS
26  
27 =head2 handler (required param)
28  
29 The handler param accepts a CODEREF/anonymous subroutine which itself receives
30 a single parameter, the data element to transfigure, and is expected to return the
31 transfigured value.
32  
33 =cut
34  
35 field $handler : param;
36  
37 =head1 METHODS
38  
39 =head2 applies_to( %params )
40  
41 C<applies_to> is required to be supplied by classes implementing this role.
42  
43 This method recieves a param hash with keys C<value> and C<position> and returns
44 a constant from C<Data::Transfigure::Constants> reflecting what degree
45 of match, if any, the transfigurator has to that node. Higher values are better
46 matches.
47  
48 =cut
49  
50 method applies_to;
51  
52 =head2 transfigure( @args )
53  
54 Executes the handler on the data element. Typically this shouldn't be called
55 manually or need to be overridden by subclasses.
56  
57 =cut
58  
59 method transfigure (@args) {
60 return $handler->(@args);
61 }
62 }
63  
64 =pod
65  
66 =head1 AUTHOR
67  
68 Mark Tyrrell C<< <mark@tyrrminal.dev> >>
69  
70 =head1 LICENSE
71  
72 Copyright (c) 2024 Mark Tyrrell
73  
74 Permission is hereby granted, free of charge, to any person obtaining a copy
75 of this software and associated documentation files (the "Software"), to deal
76 in the Software without restriction, including without limitation the rights
77 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
78 copies of the Software, and to permit persons to whom the Software is
79 furnished to do so, subject to the following conditions:
80  
81 The above copyright notice and this permission notice shall be included in all
82 copies or substantial portions of the Software.
83  
84 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
90 SOFTWARE.
91  
92 =cut
93  
94 1;
95  
96 __END__