blib/lib/Data/Tersify/Plugin/DBIx/Class.pm

filter: Statementstmt 100% 18 / 18 Branchbran 75.0% 3 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 97.2% 35 / 36 CC 4 SCAR 8.5
CC
4
Cov
96%
tersify
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
↑ Summary
1 package Data::Tersify::Plugin::DBIx::Class;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Data::Tersify 1.003;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '1.003';
9 2 $VERSION = eval $VERSION;
10  
11 =head1 NAME
12  
13 Data::Tersify::Plugin::DBIx::Class - tersify DBIx::Class objects
14  
15 =head1 VERSION
16  
17 This is version 1.003.
18  
19 =head1 SYNOPSIS
20  
21 In e.g. the perl debugger
22  
23 DB<1> use Data::Tersify;
24 DB<2> my $dbic_row = $schema->resultset(...)->find(...);
25 DB<3> x Data::Tersify::tersify($dbic_row)
26  
27 produces something like
28  
29 0 Data::Tersify::Summary::...::TableName (0xdeadbeef)=HASH(0xcafebabe)
30 '_column_data' => HASH(0x1b32ca80)
31 'date_created' => '2020-03-04 20:19:47'
32 'id' => 558
33 'status' => 'active'
34 '_in_storage' => 1
35 '_inflated_column' => HASH(0x1b318618)
36 empty hash
37 '_result_source' => Data::Tersify::Summary=SCALAR(0xbeefdead)
38 -> 'DBIx::Class::ResultSource::Table (0xbabecafe) table_name'
39 'related_resultsets' => HASH(0x7235e68)
40 'related_table' => Data::Tersify::Summary=SCALAR(0x12345678)
41 -> 'DBIx::Class::ResultSet (0x9abcdef0) ...::RelatedTable'
42  
43 rather than screenfuls of stuff you don't care about.
44  
45 If you delve into the guts of the result sources or result sets, you'll get
46 more chatty stuff, but it'll still be limited to amounts that the human brain
47 can deal with.
48  
49 =head1 DESCRIPTION
50  
51 This class provides terse description for various types of DBIx::Class
52 objects, when used with L<Data::Tersify>.
53  
54 =head2 handles
55  
56 It handles DBIx::Class::ResultSource::Table, DBIx::Class::ResultSource::View
57 and DBIx::Class::ResultSet objects. Surprisingly, that appears to be enough.
58  
59 =cut
60  
61 2 ▶sub handles {
Subroutine handles: called CC=1 SCAR=0.0
Pod documented
62 (
63 2 'DBIx::Class::ResultSource::Table',
64 'DBIx::Class::ResultSource::View',
65 'DBIx::Class::ResultSet'
66 );
67 }
68  
69 =head2 handles_subclasses
70  
71 It handles subclasses of those classes as well.
72  
73 =cut
74  
75 1 ▶sub handles_subclasses { 1 }
Subroutine handles_subclasses: called CC=1 SCAR=0.0
Pod documented
76  
77 =head2 tersify
78  
79 It tersifies DBIx::Class::ResultSource::Table or ...::View objects into just
80 the name of the table or view respectively.
81  
82 It tersifies DBIx::Class::ResultSet objects into the name of the result class.
83  
84 This tends to be the source of the vast majority of the unwanted chaff that
85 fills your screen.
86  
87 =cut
88  
89 4 ▶sub tersify {
Subroutine tersify: called CC=4 SCAR=13.9
Pod documented
90 4 my ($self, $dbic_object) = @_;
91  
92 4 ▶ if ( $dbic_object->isa('DBIx::Class::ResultSource::Table')
Branch: 2 branches
BranchTrueFalseTotal
if ($dbic_object->isa('DBIx::Class::ResultSource::Table') or $dbic_object->isa('DBIx::Class::ResultSource::View')) { } 2 2 4
elsif ($dbic_object->isa('DBIx::Class::ResultSet')) { } 2 0 2
Condition100%3/3
$dbic_object->isa("DBIx::Class::ResultSource::Table") or $dbic_object->isa("DBIx::Class::ResultSource::View")
l!l&&r!l&&!r
112
MC/DC100%2/2
$dbic_object->isa("DBIx::Class::ResultSource::Table") or $dbic_object->isa("DBIx::Class::ResultSource::View")
$dbic_object->isa("DBIx::Class::ResultSource::Table") $dbic_object->isa("DBIx::Class::ResultSource::View")
Truth table100%3/3
A or B
A= $dbic_object->isa("DBIx::Class::ResultSource::Table")B= $dbic_object->isa("DBIx::Class::ResultSource::View")
ABresult
1X1
011
000
93 || $dbic_object->isa('DBIx::Class::ResultSource::View'))
94 {
95 2 return $dbic_object->{name};
96 } elsif ($dbic_object->isa('DBIx::Class::ResultSet')) {
97 2 return $dbic_object->{_result_class};
98 }
99 }
100  
101 2 1;
102  
↑ Summary