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   1728 use Exporter::Declare;
  5         84233  
  5         20  
4              
5 5     5   7018 use Moose;
  5         12  
  5         45  
6              
7 5     5   21976 use MooseX::DIC::Types;
  5         11  
  5         1282  
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 19 my $attribute = shift;
18            
19 6         34 my %params = ( name => $attribute->name );
20 6 100       39 if( $attribute->does('MooseX::DIC::Injected') ) {
21 4 50       1368 $params{scope} = $attribute->scope if $attribute->scope;
22 4 50       153 $params{qualifiers} = $attribute->qualifiers if $attribute->qualifiers;
23             }
24              
25 6         474 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 3 my ($name,$definition) = @_;
31              
32 1         3 my %params = ( name => $name );
33 1 50       4 $params{scope} = $definition->{scope} if exists($definition->{scope});
34 1 50       3 $params{qualifiers} = $definition->{qualifiers} if exists($definition->{qualifiers});
35              
36 1         35 return MooseX::DIC::Configuration::ServiceMetadata::Dependency->new(%params);
37              
38             }
39             __PACKAGE__->meta->make_immutable;
40             1;