Objects/Base.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 94.5% 35 / 37 CC 6 SCAR 11.0
CC
6
Cov
100%
BUILD
4.0
update
3.0
BEGIN
1.0
CRAP 3.0
« Objects.pm ↑ Summary Objects/Role/Result.pm »
1 package DBIx::Class::Objects::Base;
2  
3 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use DBIx::Class::Objects::Util 'class_name_to_private_accessor';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.02';
7  
8 sub BUILD {
9 78 ▶ my $self = shift;
Subroutine BUILD: called CC=4 SCAR=13.9
Pod undocumented
10 78 my @parents = grep { $_ ne __PACKAGE__ } $self->meta->superclasses;
11  
12 78 my $source = $self->result_source;
13 78 my @relationships = $source->relationships;
14  
15 78 foreach my $relationship (@relationships) {
16 104 my $info = $source->relationship_info($relationship);
17 104 ▶ next if 'multi' eq $info->{attrs}{accessor};
Branch: 1 branch
BranchTrueFalseTotal
if "multi" eq $info->{"attrs"}{"accessor"} 28 76 104
18 76 my $parent = $info->{_result_class_to_object_class};
19 76 ▶ next unless $self->isa($parent);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa($parent) 62 14 76
20 14 my $accessor = class_name_to_private_accessor($parent);
21 14 $self->$accessor( $self->$relationship->result_source );
22 }
23 }
24  
25 sub update {
26 1 ▶ my $self = shift;
Subroutine update: called CC=3 SCAR=11.0
Pod undocumented
27  
28 1 foreach my $attribute ( $self->meta->get_all_attributes ) {
29 next
30 3 ▶ unless $attribute->does(
Branch: 1 branch
BranchTrueFalseTotal
unless $attribute->does("DBIx::Class::Objects::Attribute::Trait::DBIC") 1 2 3
31 'DBIx::Class::Objects::Attribute::Trait::DBIC');
32 2 my $name = $attribute->name;
33 2 $self->$name->update;
34 }
35 }
36  
37 3 1;
38  
39 __END__
40  
41 =head1 NAME
42  
43 DBIx::Class::Objects::Base - Base class for DBIx::Class::Objects objects
44  
45 Adds an C<update> method to the objects to allow them to also update any
46 inherited objects.
47  
48 =head1 AUTHOR
49  
50 Curtis "Ovid" Poe, C<< <ovid at cpan.org> >>
51  
52 =head1 BUGS
53  
54 Please report any bugs or feature requests to C<bug-object-bridge at
55 rt.cpan.org>, or through the web interface at
56 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-Objects>. I will be
57 notified, and then you'll automatically be notified of progress on your bug as
58 I make changes.
59  
60 =head1 SUPPORT
61  
62 You can find documentation for this module with the perldoc command.
63  
64 perldoc DBIx::Class::Objects
65  
66 You can also look for information at:
67  
68 =over 4
69  
70 =item * RT: CPAN's request tracker (report bugs here)
71  
72 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-Objects>
73  
74 =item * AnnoCPAN: Annotated CPAN documentation
75  
76 L<http://annocpan.org/dist/DBIx-Class-Objects>
77  
78 =item * CPAN Ratings
79  
80 L<http://cpanratings.perl.org/d/DBIx-Class-Objects>
81  
82 =item * Search CPAN
83  
84 L<http://search.cpan.org/dist/DBIx-Class-Objects/>
85  
86 =back
87  
88  
89 =head1 ACKNOWLEDGEMENTS
90  
91  
92 =head1 LICENSE AND COPYRIGHT
93  
94 Copyright 2014 Curtis "Ovid" Poe.
95  
96 This program is free software; you can redistribute it and/or modify it
97 under the terms of the the Artistic License (2.0). You may obtain a
98 copy of the full license at:
99  
100 L<http://www.perlfoundation.org/artistic_license_2_0>
101  
102 Any use, modification, and distribution of the Standard or Modified
103 Versions is governed by this Artistic License. By using, modifying or
104 distributing the Package, you accept this license. Do not use, modify,
105 or distribute the Package, if you do not accept this license.
106  
107 If your Modified Version has been derived from a Modified Version made
108 by someone other than you, you are nevertheless required to ensure that
109 your Modified Version complies with the requirements of this license.
110  
111 This license does not grant you the right to use any trademark, service
112 mark, tradename, or logo of the Copyright Holder.
113  
114 This license includes the non-exclusive, worldwide, free-of-charge
115 patent license to make, have made, use, offer to sell, sell, import and
116 otherwise transfer the Package with respect to any patent claims
117 licensable by the Copyright Holder that are necessarily infringed by the
118 Package. If you institute patent litigation (including a cross-claim or
119 counterclaim) against any party alleging that the Package constitutes
120 direct or contributory patent infringement, then this Artistic License
121 to you shall terminate on the date that such litigation is filed.
122  
123 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
124 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
125 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
126 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
127 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
128 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
129 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
130 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
« Objects.pm ↑ Summary Objects/Role/Result.pm »