| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::TypeMap::Shadow; | ||||||||||
| 4 | 12 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 12 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 12 | with qw(KiokuDB::Role::TypeMap); | |||||||||
| 9 | |||||||||||
| 10 | 12 | has typemaps => ( | |||||||||
| 11 | does => "ArrayRef[KiokuDB::Role::TypeMap]", | ||||||||||
| 12 | is => "ro", | ||||||||||
| 13 | required => 1, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | sub resolve { | ||||||||||
| 17 | 74 | ▶ | my ( $self, @args ) = @_; | ||||||||
|
Subroutine
resolve: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 18 | |||||||||||
| 19 | 74 | foreach my $typemap ( @{ $self->typemaps } ) { | |||||||||
| 20 | 159 | ▶ | if ( my $entry = $typemap->resolve(@args) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 57 | return $entry; | |||||||||
| 22 | } | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 17 | return; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 12 | __PACKAGE__->meta->make_immutable; | |||||||||
| 29 | |||||||||||
| 30 | 12 | __PACKAGE__ | |||||||||
| 31 | |||||||||||
| 32 | __END__ | ||||||||||
| 33 | |||||||||||
| 34 | =pod | ||||||||||
| 35 | |||||||||||
| 36 | =head1 NAME | ||||||||||
| 37 | |||||||||||
| 38 | KiokuDB::TypeMap::Shadow - Try a list of L<KiokuDB::TypeMap>s in order | ||||||||||
| 39 | |||||||||||
| 40 | =head1 SYNOPSIS | ||||||||||
| 41 | |||||||||||
| 42 | KiokuDB->new( | ||||||||||
| 43 | backend => ..., | ||||||||||
| 44 | typemap => KiokuDB::TypeMap::Shadow->new( | ||||||||||
| 45 | typemaps => [ | ||||||||||
| 46 | $first, | ||||||||||
| 47 | $second, | ||||||||||
| 48 | ], | ||||||||||
| 49 | ), | ||||||||||
| 50 | ); | ||||||||||
| 51 | |||||||||||
| 52 | =head1 DESCRIPTION | ||||||||||
| 53 | |||||||||||
| 54 | This class is useful for performing mixin inheritence like merging of typemaps, | ||||||||||
| 55 | by shadowing an ordered list. | ||||||||||
| 56 | |||||||||||
| 57 | This is used internally to overlay the user typemap on top of the | ||||||||||
| 58 | L<KiokuDB::TypeMap::Default> instance provided by the backend. | ||||||||||
| 59 | |||||||||||
| 60 | This differs from using C<includes> in L<KiokuDB::TypeMap> because that | ||||||||||
| 61 | inclusion is computed symmetrically, like roles. | ||||||||||
| 62 | |||||||||||
| 63 | =cut | ||||||||||