| 1 | package Data::Transfigure::Tree 1.03; | ||
| 2 | use v5.26; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | # ABSTRACT: a transfigurator that is applied to the entire data structure | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Data::Transfigure::Tree - a transfigurator that is applied to the entire data | ||
| 10 | structure, after all "node" transfigurations have been completed | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | C<Data::Transfigure::Tree> transfigurators are used to "clean-up" the data | ||
| 15 | structure after all other transfigurations have been applied. | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | use Object::Pad; | ||
| 20 | |||
| 21 | role Data::Transfigure::Tree { | ||
| 22 | field $handler : param; | ||
| 23 | |||
| 24 | =head1 METHODS | ||
| 25 | |||
| 26 | =head2 transfigure( @args ) | ||
| 27 | |||
| 28 | Executes the handler on the entire data structure. Typically this shouldn't be | ||
| 29 | called manually or need to be overridden by subclasses. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | method transfigure (@args) { | ||
| 34 | return $handler->(@args); | ||
| 35 | } | ||
| 36 | |||
| 37 | } | ||
| 38 | |||
| 39 | =pod | ||
| 40 | |||
| 41 | =head1 AUTHOR | ||
| 42 | |||
| 43 | Mark Tyrrell C<< <mark@tyrrminal.dev> >> | ||
| 44 | |||
| 45 | =head1 LICENSE | ||
| 46 | |||
| 47 | Copyright (c) 2024 Mark Tyrrell | ||
| 48 | |||
| 49 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 50 | of this software and associated documentation files (the "Software"), to deal | ||
| 51 | in the Software without restriction, including without limitation the rights | ||
| 52 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 53 | copies of the Software, and to permit persons to whom the Software is | ||
| 54 | furnished to do so, subject to the following conditions: | ||
| 55 | |||
| 56 | The above copyright notice and this permission notice shall be included in all | ||
| 57 | copies or substantial portions of the Software. | ||
| 58 | |||
| 59 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 60 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 61 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 62 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 63 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 64 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 65 | SOFTWARE. | ||
| 66 | |||
| 67 | =cut | ||
| 68 | |||
| 69 | 1; | ||
| 70 | |||
| 71 | __END__ |