Board/Dependency.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 93.9% 31 / 33 CC 3 SCAR 4.6
CC
3
Cov
93%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.6
« Board/LifeCycle/Singleton.pm ↑ Summary Board/SetterInjection.pm »
1 package Bread::Board::Dependency;
2 77 our $AUTHORITY = 'cpan:STEVAN';
3 # ABSTRACT: dependency for a service
4 77 $Bread::Board::Dependency::VERSION = '0.36';
5 77 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 77 ▶use Bread::Board::Service;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 77 with 'Bread::Board::Traversable';
10  
11 77 has 'service_path' => (
12 is => 'ro',
13 isa => 'Str',
14 predicate => 'has_service_path'
15 );
16  
17 has 'service_name' => (
18 is => 'ro',
19 isa => 'Str',
20 lazy => 1,
21 default => sub {
22 47 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=7.1
23 47 ▶ ($self->has_service_path)
Branch: 1 branch
BranchTrueFalseTotal
$self->has_service_path or confess("Could not determine service name without service path") 0 47 47
24 || confess "Could not determine service name without service path";
25 47 (split '/' => $self->service_path)[-1];
26 }
27 77 );
28  
29 77 has 'service_params' => (
30 is => 'ro',
31 isa => 'HashRef',
32 predicate => 'has_service_params'
33 );
34  
35 has 'service' => (
36 is => 'ro',
37 does => 'Bread::Board::Service | Bread::Board::Dependency',
38 lazy => 1,
39 default => sub {
40 109 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=7.1
41 109 ▶ ($self->has_service_path)
Branch: 1 branch
BranchTrueFalseTotal
$self->has_service_path or confess("Could not fetch service without service path") 0 109 109
42 || confess "Could not fetch service without service path";
43 109 $self->fetch($self->service_path);
44 },
45 77 handles => [ 'get', 'is_locked', 'lock', 'unlock' ]
46 );
47  
48 77 __PACKAGE__->meta->make_immutable;
49  
50 77 ▶no Moose; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 __END__
53  
54 =pod
55  
56 =encoding UTF-8
57  
58 =head1 NAME
59  
60 Bread::Board::Dependency - dependency for a service
61  
62 =head1 VERSION
63  
64 version 0.36
65  
66 =head1 DESCRIPTION
67  
68 This class holds the information for a dependency of a
69 L<service|Bread::Board::Service::WithDependencies>. When L<resolving
70 dependencies|Bread::Board::Service::WithDependencies/resolve_dependencies>,
71 instances of this class will be used to access the services that will
72 provide the depended-on values.
73  
74 This class consumes the L<Bread::Board::Traversable> role to retrieve
75 services given their path.
76  
77 =head1 ATTRIBUTES
78  
79 =head2 C<service_path>
80  
81 The path to use (possibly relative to the dependency itself) to access
82 the L</service>.
83  
84 =head2 C<service>
85  
86 The service this dependency points at. Usually built lazily from the
87 L</service_path>, but could just be passed in to the constructor.
88  
89 =head2 C<service_name>
90  
91 Name of the L</service>, defaults to the last element of the
92 L</service_path>.
93  
94 =head1 METHODS
95  
96 =head2 C<has_service_path>
97  
98 Predicate for the L</service_path> attribute.
99  
100 =head2 C<get>
101  
102 =head2 C<is_locked>
103  
104 =head2 C<lock>
105  
106 =head2 C<unlock>
107  
108 These methods are delegated to the L</service>.
109  
110 =head1 AUTHOR
111  
112 Stevan Little <stevan@iinteractive.com>
113  
114 =head1 BUGS
115  
116 Please report any bugs or feature requests on the bugtracker website
117 https://github.com/stevan/BreadBoard/issues
118  
119 When submitting a bug or request, please include a test-file or a
120 patch to an existing test-file that illustrates the bug or desired
121 feature.
122  
123 =head1 COPYRIGHT AND LICENSE
124  
125 This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive.
126  
127 This is free software; you can redistribute it and/or modify it under
128 the same terms as the Perl 5 programming language system itself.
129  
130 =cut
« Board/LifeCycle/Singleton.pm ↑ Summary Board/SetterInjection.pm »