File Coverage

blib/lib/Forest/Tree/Roles/LoadWithMetaData.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Forest::Tree::Roles::LoadWithMetaData;
2 1     1   6018 use Moose::Role;
  1         3  
  1         11  
3              
4             our $VERSION = '0.10';
5             our $AUTHORITY = 'cpan:STEVAN';
6              
7             has 'metadata' => (
8             is => 'rw',
9             isa => 'HashRef',
10             default => sub { {} },
11             );
12              
13             has 'metadata_key' => (
14             is => 'rw',
15             isa => 'Str',
16             default => sub { 'uid' },
17             );
18              
19             around 'create_new_subtree' => sub {
20             my $next = shift;
21             my $self = shift;
22             my $tree = $self->$next(@_);
23              
24             ($tree->does('Forest::Tree::Roles::MetaData'))
25             || confess "Your subtrees must do the MetaData role";
26              
27             my $key = $self->metadata_key;
28             if (my $metadata = $self->metadata->{ $tree->$key() }) {
29             $tree->metadata($metadata);
30             }
31              
32             return $tree;
33             };
34              
35 1     1   9225 no Moose::Role; 1;
  1         3  
  1         81  
36              
37             __END__
38              
39             =pod
40              
41             =head1 NAME
42              
43             Forest::Tree::Roles::LoadWithMetaData - A Moosey solution to this problem
44              
45             =head1 SYNOPSIS
46              
47             use Forest::Tree::Roles::LoadWithMetaData;
48              
49             =head1 DESCRIPTION
50              
51             =head1 METHODS
52              
53             =over 4
54              
55             =item B<>
56              
57             =back
58              
59             =head1 BUGS
60              
61             All complex software has bugs lurking in it, and this module is no
62             exception. If you find a bug please either email me, or add the bug
63             to cpan-RT.
64              
65             =head1 AUTHOR
66              
67             Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
68              
69             =head1 COPYRIGHT AND LICENSE
70              
71             Copyright 2008-2014 Infinity Interactive, Inc.
72              
73             L<http://www.iinteractive.com>
74              
75             This library is free software; you can redistribute it and/or modify
76             it under the same terms as Perl itself.
77              
78             =cut