line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 provides a method to compare if two objects are the |
18
|
|
|
|
|
|
|
same. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
74
|
|
|
74
|
|
34126
|
use Moo::Role; |
|
74
|
|
|
|
|
185
|
|
|
74
|
|
|
|
|
402
|
|
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
|
|
|
|
|
|
|
sub equals { |
35
|
766
|
|
|
766
|
1
|
1192
|
my $self = shift; |
36
|
766
|
|
|
|
|
1070
|
my $other = shift; |
37
|
|
|
|
|
|
|
|
38
|
766
|
50
|
|
|
|
1704
|
return 0 unless $other; |
39
|
766
|
100
|
|
|
|
7292
|
return 1 if overload::StrVal($self) eq overload::StrVal($other); |
40
|
686
|
50
|
|
|
|
6501
|
return 0 unless $other->isa( ref($self) ); |
41
|
686
|
|
|
|
|
1866
|
return 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _compare_objects { |
45
|
|
|
|
|
|
|
# my ($self, $obj1, $obj2) = @_; |
46
|
|
|
|
|
|
|
|
47
|
452
|
|
|
452
|
|
2185
|
my $result = ( |
48
|
|
|
|
|
|
|
Data::Dumper->new([$_[1]])->Terse(1)->Indent(0)->Deparse(1)->Sortkeys(1)->Maxdepth(0)->Dump |
49
|
|
|
|
|
|
|
eq |
50
|
|
|
|
|
|
|
Data::Dumper->new([$_[2]])->Terse(1)->Indent(0)->Deparse(1)->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
|
452
|
|
|
|
|
52191
|
return $result; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |