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 5     5   1865 use Exporter::Declare;
  5         102911  
  5         25  
4              
5 5     5   8073 use Moose;
  5         15  
  5         47  
6              
7 5     5   28026 use MooseX::DIC::Types;
  5         12  
  5         1609  
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 22 my $attribute = shift;
18            
19 6         38 my %params = ( name => $attribute->name );
20 6 100       47 if( $attribute->does('MooseX::DIC::Injected') ) {
21 4 50       1573 $params{scope} = $attribute->scope if $attribute->scope;
22 4 50       162 $params{qualifiers} = $attribute->qualifiers if $attribute->qualifiers;
23             }
24              
25 6         969 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 5 my ($name,$definition) = @_;
31              
32 1         5 my %params = ( name => $name );
33 1 50       9 $params{scope} = $definition->{scope} if exists($definition->{scope});
34 1 50       5 $params{qualifiers} = $definition->{qualifiers} if exists($definition->{qualifiers});
35              
36 1         62 return MooseX::DIC::Configuration::ServiceMetadata::Dependency->new(%params);
37              
38             }
39             __PACKAGE__->meta->make_immutable;
40             1;