File Coverage

blib/lib/IOC/Service/Prototype.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 23 23 100.0


line stmt bran cond sub pod time code
1              
2             package IOC::Service::Prototype;
3              
4 11     11   78554 use strict;
  11         27  
  11         2090  
5 11     11   64 use warnings;
  11         20  
  11         469  
6              
7             our $VERSION = '0.02';
8              
9 11     11   1113 use IOC::Exceptions;
  11         20  
  11         267  
10              
11 11     11   64 use base 'IOC::Service';
  11         29  
  11         2423  
12              
13             sub instance {
14 21     21 1 21974 my ($self) = @_;
15 21 100       100 (defined($self->{container}))
16             || throw IOC::IllegalOperation "Cannot create a service instance without setting container";
17             # we need to be sure to not store this value
18             # otherwise we will add a ref count to it
19 20         172 return $self->{block}->($self->{container});
20             }
21              
22             1;
23              
24             __END__