Transfigure/Type/DBIx.pm

filter: Statementstmt 75.0% 6 / 8 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 81.8% 9 / 11 CC 1 SCAR 0.9
CC
1
Cov
75%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Transfigure/Type.pm ↑ Summary Transfigure/Type/DBIx/Recursive.pm »
1 package Data::Transfigure::Type::DBIx 1.03;
2 1 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: transfigures DBIx::Class::Rows into hashrefs
6  
7 =head1 NAME
8  
9 Data::Transfigure::Type::DBIx - transfigures DBIx::Class::Rows into hashrefs
10  
11 =head1 DESCRIPTION
12  
13 C<Data::Transfigure::Type::DBIx> is used to transfigure L<DBIx::Class::Row>
14 instances into JSON-able structures, using C<get_inflated_columns> to get make
15 a hashref from the object's keys (column names) and values.
16  
17 This transfigurator does not traverse relationships, and instead just outputs the
18 foreign key column's name and id value.
19  
20 =cut
21  
22 0 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=2.6
23  
24 use Data::Transfigure::Type;
25 class Data::Transfigure::Type::DBIx : isa(Data::Transfigure::Type) {
26  
27 =head1 FIELDS
28  
29 I<none>
30  
31 =cut
32  
33 sub BUILDARGS ($class) {
34 $class->SUPER::BUILDARGS(
35 type => qw(DBIx::Class::Row),
36 handler => sub ($data) {
37 return {$data->get_inflated_columns};
38 }
39 );
40 }
41  
42 }
43  
44 =pod
45  
46 =head1 AUTHOR
47  
48 Mark Tyrrell C<< <mark@tyrrminal.dev> >>
49  
50 =head1 LICENSE
51  
52 Copyright (c) 2024 Mark Tyrrell
53  
54 Permission is hereby granted, free of charge, to any person obtaining a copy
55 of this software and associated documentation files (the "Software"), to deal
56 in the Software without restriction, including without limitation the rights
57 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58 copies of the Software, and to permit persons to whom the Software is
59 furnished to do so, subject to the following conditions:
60  
61 The above copyright notice and this permission notice shall be included in all
62 copies or substantial portions of the Software.
63  
64 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
70 SOFTWARE.
71  
72 =cut
73  
74 1;
75  
76 __END__
« Transfigure/Type.pm ↑ Summary Transfigure/Type/DBIx/Recursive.pm »