| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 1453 | use 5.008;    #utf8 | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 45 |  | 
| 2 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 3 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 109 |  | 
| 4 | 1 |  |  | 1 |  | 1069 | use utf8; | 
|  | 1 |  |  |  |  | 11 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | package Git::PurePerl::Walker::Role::HasRepo; | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | our $VERSION = '0.004000'; | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | # ABSTRACT: An entity that has a repo | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 1 |  |  | 1 |  | 1293 | use Moose::Role qw( with has ); | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | use Git::PurePerl::Walker::Types qw( GPPW_Repository ); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | with qw( MooseX::Clone ); | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | has '_repo' => ( isa => GPPW_Repository, is => 'rw', weak_ref => 1 ); | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | sub for_repository { | 
| 67 |  |  |  |  |  |  | my ( $self, $repo ) = @_; | 
| 68 |  |  |  |  |  |  | my $clone = $self->clone( _repo => $repo, ); | 
| 69 |  |  |  |  |  |  | return $clone; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | no Moose::Role; | 
| 73 |  |  |  |  |  |  | 1; | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | __END__ | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =pod | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =encoding UTF-8 | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =head1 NAME | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | Git::PurePerl::Walker::Role::HasRepo - An entity that has a repo | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =head1 VERSION | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | version 0.004000 | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | This is a composition role consumed by other roles to provide them with a | 
| 92 |  |  |  |  |  |  | private repo property. | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | This role also folds in L<< C<MooseX::B<Clone>>|MooseX::Clone >> and provides the 'for_repository' | 
| 95 |  |  |  |  |  |  | method which sets the repo property. | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | package Foo { | 
| 98 |  |  |  |  |  |  | use Moose; | 
| 99 |  |  |  |  |  |  | with 'Git::PurePerl::Walker::Role::HasRepo'; | 
| 100 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | my $factory = Foo->new( %args ); | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | my $instance = $factory->for_repository( $Git_PurePerl_Repo ); | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =head1 METHODS | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | =head2 for_repository | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | Construct an entity for a given repository. | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | This internally calls L<< C<MooseX::B<Clone>>|MooseX::Clone >> on the current object, passing the _repo | 
| 114 |  |  |  |  |  |  | field to its constructor, producing a separate, disconnected object to work | 
| 115 |  |  |  |  |  |  | with. | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | The rationale behind this is simple: Its very likely users will want one set of | 
| 118 |  |  |  |  |  |  | settings for a consuming class, but they'll want to use those same settings with | 
| 119 |  |  |  |  |  |  | multiple repositories. | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | And as each repository will need to maintain its own state for traversal, they | 
| 122 |  |  |  |  |  |  | have to normally manually construct an object for each repository, manually | 
| 123 |  |  |  |  |  |  | disconnecting the constructor arguments. | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | This instead is simple: | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | my $thing = Thing->new( %args ); | 
| 128 |  |  |  |  |  |  | my ( @foos  ) = map { $thing->for_repository( $_ ) } @repos; | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | And now all C<@foos> can be mangled independently. | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =head1 INHERITED METHODS | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =head2 clone | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | L<< C<MooseX::B<Clone>-E<gt>I<clone( %params )>>|MooseX::Clone/clone-params >> | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =head1 PRIVATE ATTRIBUTES | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =head2 _repo | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =head1 PRIVATE ATTRIBUTE GENERATED METHODS | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =head2 _repo | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | =head1 CONSUMED ROLES | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | =head2 MooseX::Clone | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | L<< C<MooseX::B<Clone>>|MooseX::Clone >> | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | =head1 AUTHOR | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | Kent Fredric <kentnl@cpan.org> | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  | This software is copyright (c) 2014 by Kent Fredric <kentnl@cpan.org>. | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 161 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  | =cut |