File Coverage

blib/lib/Forest/Tree/Indexer/SimpleUIDIndexer.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 4 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Forest::Tree::Indexer::SimpleUIDIndexer;
2 4     4   16040 use Moose;
  4         11  
  4         38  
3              
4             our $VERSION = '0.10';
5             our $AUTHORITY = 'cpan:STEVAN';
6              
7             with 'Forest::Tree::Indexer';
8              
9             sub build_index {
10 3     3 1 1802 my $self = shift;
11 3         20 my $root = $self->get_root;
12 3         121 my $index = $self->index;
13              
14 3 50       122 (!exists $index->{$root->uid})
15             || confess "Tree root has already been indexed, you must clear it before re-indexing";
16              
17 3         102 $index->{$root->uid} = $root;
18              
19             $root->traverse(sub {
20 21     21   28 my $t = shift;
21 21 50       704 (!exists $index->{$t->uid})
22             || confess "Duplicate tree id (" . $t->uid . ") found";
23 21         670 $index->{$t->uid} = $t;
24 3         36 });
25              
26             };
27              
28             __PACKAGE__->meta->make_immutable;
29              
30 4     4   41985 no Moose; 1;
  4         46  
  4         28  
31              
32             __END__
33              
34             =pod
35              
36             =head1 NAME
37              
38             Forest::Tree::Indexer::SimpleUIDIndexer - Indexes a Forest::Tree heiarchy by it's UID
39              
40             =head1 DESCRIPTION
41              
42             This creates an index of a Forest::Tree heiarchy using the UID as the key.
43              
44             =head1 METHODS
45              
46             =over 4
47              
48             =item B<build_index>
49              
50             =back
51              
52             =head1 BUGS
53              
54             All complex software has bugs lurking in it, and this module is no
55             exception. If you find a bug please either email me, or add the bug
56             to cpan-RT.
57              
58             =head1 AUTHOR
59              
60             Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
61              
62             =head1 COPYRIGHT AND LICENSE
63              
64             Copyright 2008-2014 Infinity Interactive, Inc.
65              
66             L<http://www.iinteractive.com>
67              
68             This library is free software; you can redistribute it and/or modify
69             it under the same terms as Perl itself.
70              
71             =cut