Objects/Role/Result.pm

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