File Coverage

blib/lib/Bolts/Injector/Parameter/ByName.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 11 11 100.0


line stmt bran cond sub pod time code
1             package Bolts::Injector::Parameter::ByName;
2             $Bolts::Injector::Parameter::ByName::VERSION = '0.142930';
3             # ABSTRACT: Inject parameters by name during construction
4              
5 8     8   35 use Moose;
  8         12  
  8         47  
6              
7             with 'Bolts::Injector';
8              
9              
10             has name => (
11             is => 'ro',
12             isa => 'Str',
13             lazy_build => 1,
14             );
15              
16 57     57   1500 sub _build_name { $_[0]->key }
17              
18              
19             sub pre_inject_value {
20 276     276 1 322 my ($self, $loc, $value, $params) = @_;
21 276         266 push @{ $params }, $self->name, $value;
  276         7752  
22             }
23              
24             __PACKAGE__->meta->make_immutable;
25              
26             __END__
27              
28             =pod
29              
30             =encoding UTF-8
31              
32             =head1 NAME
33              
34             Bolts::Injector::Parameter::ByName - Inject parameters by name during construction
35              
36             =head1 VERSION
37              
38             version 0.142930
39              
40             =head1 SYNOPSIS
41              
42             use Bolts;
43              
44             artifact thing => (
45             class => 'MyApp::Thing',
46             parameters => {
47             foo => dep('other_thing'),
48             },
49             );
50              
51             =head1 DESCRIPTION
52              
53             Inject parameters by name during construction.
54              
55             =head1 ROLES
56              
57             =over
58              
59             =item *
60              
61             L<Bolts::Injector>
62              
63             =back
64              
65             =head1 ATTRIBUTES
66              
67             =head2 name
68              
69             This is the name of the parameter to set in the call to the constructor.
70              
71             =head1 METHODS
72              
73             =head2 pre_inject_value
74              
75             Performs the pre-injection by named parameter.
76              
77             =head1 AUTHOR
78              
79             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
80              
81             =head1 COPYRIGHT AND LICENSE
82              
83             This software is copyright (c) 2014 by Qubling Software LLC.
84              
85             This is free software; you can redistribute it and/or modify it under
86             the same terms as the Perl 5 programming language system itself.
87              
88             =cut