File Coverage

blib/lib/IOC/Service/Literal.pm
Criterion Covered Total %
statement 30 30 100.0
branch 4 4 100.0
condition 1 3 33.3
subroutine 11 11 100.0
pod 4 4 100.0
total 50 52 96.1


line stmt bran cond sub pod time code
1              
2             package IOC::Service::Literal;
3              
4 9     9   57613 use strict;
  9         18  
  9         289  
5 9     9   87 use warnings;
  9         16  
  9         353  
6              
7             our $VERSION = '0.01';
8              
9 9     9   46 use Scalar::Util qw(blessed);
  9         17  
  9         490  
10              
11 9     9   541 use IOC::Exceptions;
  9         17  
  9         201  
12              
13 9     9   46 use base 'IOC::Service';
  9         14  
  9         3826  
14              
15             sub new {
16 14     14 1 1056 my ($_class, $name, $literal) = @_;
17 14   33     81 my $class = ref($_class) || $_class;
18 14         75 my $service = {};
19 14         180 bless($service, $class);
20 14         61 $service->_init($name, $literal);
21 12         63 return $service;
22             }
23              
24             sub _init {
25 14     14   29 my ($self, $name, $literal) = @_;
26 14 100       65 (defined($name)) || throw IOC::InsufficientArguments "Service object cannot be created without a name";
27 13 100       46 (defined($literal))
28             || throw IOC::InsufficientArguments "Service::Literal object cannot be created without value";
29             # set the defaults
30 12         112 $self->{_instance} = $literal;
31             # assign constructor args
32 12         41 $self->{name} = $name;
33             # No block in this one
34             ## $self->{block} = undef;
35             # No container in this one either
36             ## $self->{container} = undef;
37             }
38              
39 26     26 1 213 sub instance { (shift)->{_instance} }
40              
41             # no-ops
42 12     12 1 149 sub setContainer { () }
43 1     1 1 5 sub removeContainer { () }
44 9     9   1760 sub DESTROY { () }
45              
46             1;
47              
48             __END__