blib/lib/SQL/Translator/Schema/Role/Compare.pm

filter: Statementstmt 100% 12 / 12 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 90.9% 20 / 22 CC 4 SCAR 11.1
CC
4
Cov
89%
equals
4.1
BEGIN
1.0
_compare_objects
1.0
CRAP 3.0
« blib/lib/SQL/Translator/Producer/TT/Base.pm ↑ Summary blib/lib/SQL/Translator/Role/Error.pm »
1 package SQL::Translator::Schema::Role::Compare;
2  
3 =head1 NAME
4  
5 SQL::Translator::Schema::Role::Compare - compare objects
6  
7 =head1 SYNOPSIS
8  
9 package Foo;
10 use Moo;
11 with qw(SQL::Translator::Schema::Role::Compare);
12  
13 $obj->equals($other);
14  
15 =head1 DESCRIPTION
16  
17 This L<Moo::Role> provides a method to compare if two objects are the
18 same.
19  
20 =cut
21  
22 77 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =head1 METHODS
25  
26 =head2 equals
27  
28 Determines if this object is the same as another.
29  
30 my $isIdentical = $object1->equals( $object2 );
31  
32 =cut
33  
34 950 ▶sub equals {
Subroutine equals: called CC=4 SCAR=14.0
Pod documented
35 950 my $self = shift;
36 950 my $other = shift;
37  
38 950 ▶ return 0 unless $other;
Branch: 1 branch
BranchTrueFalseTotal
unless $other 0 950 950
39 950 ▶ return 1 if overload::StrVal($self) eq overload::StrVal($other);
Branch: 1 branch
BranchTrueFalseTotal
if overload::StrVal($self) eq overload::StrVal($other) 81 869 950
40 869 ▶ return 0 unless $other->isa(ref($self));
Branch: 1 branch
BranchTrueFalseTotal
unless $other->isa(ref $self) 0 869 869
41 869 return 1;
42 }
43  
44 611 ▶sub _compare_objects {
Subroutine _compare_objects: called CC=1 SCAR=0.0
45  
46 # my ($self, $obj1, $obj2) = @_;
47  
48 611 my $result = (Data::Dumper->new([ $_[1] ])->Terse(1)->Indent(0)->Deparse(1)
49 ->Sortkeys(1)->Maxdepth(0)->Dump eq Data::Dumper->new([ $_[2] ])->Terse(1)->Indent(0)->Deparse(1)
50 ->Sortkeys(1)->Maxdepth(0)->Dump);
51  
52 # if ( !$result ) {
53 # use Carp qw(cluck);
54 # cluck("How did I get here?");
55 # use Data::Dumper;
56 # $Data::Dumper::Maxdepth = 1;
57 # print "obj1: ", Dumper($obj1), "\n";
58 # print "obj2: ", Dumper($obj2), "\n";
59 # }
60 611 return $result;
61 }
62  
63 77 1;
« blib/lib/SQL/Translator/Producer/TT/Base.pm ↑ Summary blib/lib/SQL/Translator/Role/Error.pm »