File Coverage

blib/lib/Bolts/Injector/Store/Hash.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 10 10 100.0


line stmt bran cond sub pod time code
1             package Bolts::Injector::Store::Hash;
2             $Bolts::Injector::Store::Hash::VERSION = '0.143171';
3             # ABSTRACT: Inject values into a hash
4              
5 1     1   780 use Moose;
  1         2  
  1         6  
6              
7             with 'Bolts::Injector';
8              
9              
10             has name => (
11             is => 'ro',
12             isa => 'Str',
13             lazy_build => 1,
14             );
15              
16 4     4   91 sub _build_name { $_[0]->key }
17              
18              
19             sub post_inject_value {
20 4     4 1 5 my ($self, $loc, $value, $hash) = @_;
21 4         93 $hash->{ $self->name } = $value;
22             }
23              
24              
25             1;
26              
27             __END__
28              
29             =pod
30              
31             =encoding UTF-8
32              
33             =head1 NAME
34              
35             Bolts::Injector::Store::Hash - Inject values into a hash
36              
37             =head1 VERSION
38              
39             version 0.143171
40              
41             =head1 SYNOPSIS
42              
43             use Bolts;
44              
45             my $counter = 0;
46             artifact thing => (
47             builder => sub { +{} },
48             keys => {
49             counter => builder { ++$counter },
50             },
51             );
52              
53             =head1 DESCRIPTION
54              
55             This performs injection of a value into a hash.
56              
57             =head1 ROLES
58              
59             =over
60              
61             =item *
62              
63             L<Bolts::Injector>
64              
65             =back
66              
67             =head1 ATTRIBUTES
68              
69             =head2 name
70              
71             This is the name of the hash key to perform injection upon.
72              
73             Defaults to the L<Bolts::Injector/key>.
74              
75             =head1 METHODS
76              
77             =head2 post_inject_value
78              
79             Performs the injection into a hash by key.
80              
81             =head1 AUTHOR
82              
83             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2014 by Qubling Software LLC.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut