Bolts/Injector/Setter.pm

filter: Statementstmt 100% 18 / 18 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 83.8% 26 / 31 SCAR 11.1
CC
3
Cov
87%
post_inject_value
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« Bolts/Meta/Locator.pm ↑ Summary Bolts/Meta/Initializer.pm »
1 package Bolts::Injector::Setter;
2 1 $Bolts::Injector::Setter::VERSION = '0.143170';
3 # ABSTRACT: Inject by calling a setter method with a value
4  
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 with 'Bolts::Injector';
8  
9 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 1 has name => (
14 is => 'ro',
15 isa => 'Str',
16 lazy_build => 1,
17 );
18  
19 1 ▶sub _build_name { $_[0]->key }
Subroutine _build_name: called CC=1 SCAR=0.0
20  
21  
22 sub post_inject_value {
23 2 ▶ my ($self, $loc, $value, $object) = @_;
Subroutine post_inject_value: called CC=3 SCAR=12.0
Pod documented
24  
25 2 ▶ Carp::croak(qq[Can't use setter injection on "$object".])
Branch: 1 branch
BranchTrueFalseTotal
unless defined $object and builtin::blessed($object) 0 2 2
Condition33%1/3
defined $object and builtin::blessed($object)
!ll&&!rl&&r
002
MC/DC0%0/2
defined $object and builtin::blessed($object)
defined $object builtin::blessed($object)
Truth table33%1/3
A and B
A= defined $objectB= builtin::blessed($object)
ABresult
0X0
100
111
26 unless defined $object and Scalar::Util::blessed($object);
27  
28 2 my $name = $self->name;
29 2 $object->$name($value);
30 }
31  
32 1 __PACKAGE__->meta->make_immutable;
33  
34 __END__
35  
36 =pod
37  
38 =encoding UTF-8
39  
40 =head1 NAME
41  
42 Bolts::Injector::Setter - Inject by calling a setter method with a value
43  
44 =head1 VERSION
45  
46 version 0.143170
47  
48 =head1 SYNOPSIS
49  
50 use Bolts;
51  
52 artifact thing => (
53 class => 'MyApp::Thing',
54 setters => {
55 set_foo => dep('other_thing'),
56 },
57 );
58  
59 =head1 DESCRIPTION
60  
61 This controls injection by setter, which causes a method to be called on the constructed artifact with the value to be injected.
62  
63 =head1 ROLES
64  
65 =over
66  
67 =item *
68  
69 L<Bolts::Injector>
70  
71 =back
72  
73 =head1 ATTRIBUTES
74  
75 =head2 name
76  
77 This is the name of the method to call during injection. It defaults to L<Bolts::Injector/key>.
78  
79 =head1 METHODS
80  
81 =head2 post_inject_value
82  
83 Performs the injection into the setter.
84  
85 =head1 AUTHOR
86  
87 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
88  
89 =head1 COPYRIGHT AND LICENSE
90  
91 This software is copyright (c) 2014 by Qubling Software LLC.
92  
93 This is free software; you can redistribute it and/or modify it under
94 the same terms as the Perl 5 programming language system itself.
95  
96 =cut
« Bolts/Meta/Locator.pm ↑ Summary Bolts/Meta/Initializer.pm »