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