Objects/Base.pm

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