File Coverage

lib/MooseX/DIC/Configuration/ServiceMetadata/Dependency.pm
Criterion Covered Total %
statement 20 20 100.0
branch 6 10 60.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 31 37 83.7


line stmt bran cond sub pod time code
1             package MooseX::DIC::Configuration::ServiceMetadata::Dependency;
2              
3 4     4   1315 use Exporter::Declare;
  4         59606  
  4         16  
4              
5 4     4   6213 use Moose;
  4         9  
  4         30  
6              
7 4     4   16781 use MooseX::DIC::Types;
  4         10  
  4         955  
8              
9             exports qw/ from_attribute from_yaml/;
10              
11             has name => (is => 'ro', isa => 'Str', required => 1);
12             has scope => ( is => 'ro', isa => 'InjectionScope', default => 'object' );
13             has qualifiers => ( is => 'ro', isa => 'ArrayRef[Str]', default => sub { [] } );
14              
15             # ( attribute: Moose::Meta::Attribute ) -> :Dependency
16             sub from_attribute {
17 6     6 0 82 my $attribute = shift;
18            
19 6         32 my %params = ( name => $attribute->name );
20 6 100       37 if( $attribute->does('MooseX::DIC::Injected') ) {
21 4 50       1269 $params{scope} = $attribute->scope if $attribute->scope;
22 4 50       106 $params{qualifiers} = $attribute->qualifiers if $attribute->qualifiers;
23             }
24              
25 6         523 return MooseX::DIC::Configuration::ServiceMetadata::Dependency->new(%params);
26             }
27              
28             # ( dependency_name: Str, dependency_definition: HashRef) -> Dependency
29             sub from_yaml {
30 1     1 0 2 my ($name,$definition) = @_;
31              
32 1         4 my %params = ( name => $name );
33 1 50       3 $params{scope} = $definition->{scope} if exists($definition->{scope});
34 1 50       4 $params{qualifiers} = $definition->{qualifiers} if exists($definition->{qualifiers});
35              
36 1         34 return MooseX::DIC::Configuration::ServiceMetadata::Dependency->new(%params);
37              
38             }
39             __PACKAGE__->meta->make_immutable;
40             1;