File Coverage

lib/Ubic/Multiservice/Simple.pm
Criterion Covered Total %
statement 29 30 96.6
branch 2 2 100.0
condition 2 3 66.6
subroutine 10 11 90.9
pod 5 5 100.0
total 48 51 94.1


line stmt bran cond sub pod time code
1             package Ubic::Multiservice::Simple;
2             $Ubic::Multiservice::Simple::VERSION = '1.58_01'; # TRIAL
3 2     2   61286 use strict;
  2         2  
  2         50  
4 2     2   7 use warnings;
  2         2  
  2         67  
5              
6             # ABSTRACT: simplest multiservice, configured in constructor
7              
8              
9 2     2   988 use Params::Validate qw(:all);
  2         13607  
  2         417  
10 2     2   15 use Scalar::Util qw(blessed);
  2         3  
  2         173  
11 2     2   577 use parent qw(Ubic::Multiservice);
  2         304  
  2         12  
12              
13             sub new {
14 9     9 1 2207 my $class = shift;
15             my ($params) = validate_pos(@_, {
16             type => HASHREF,
17             callbacks => {
18             'values are services' => sub {
19 9     9   41 for (values %{shift()}) {
  9         22  
20 12 100 66     273 return unless blessed($_) and $_->isa('Ubic::Service')
21             }
22 8         25 return 1;
23             },
24             }
25 9         104 });
26 8         61 return bless { services => $params } => $class;
27             }
28              
29             sub has_simple_service($$) {
30 8     8 1 11 my ($self, $name) = @_;
31 8         41 return exists $self->{services}{$name};
32             }
33              
34             sub simple_service($$) {
35 14     14 1 18 my ($self, $name) = @_;
36 14         24 return $self->{services}{$name};
37             }
38              
39             sub service_names($) {
40 3     3 1 6 my $self = shift;
41 3         2 return keys %{ $self->{services} };
  3         21  
42             }
43              
44             sub multiop {
45 0     0 1   return 'allowed'; # simple multiservices are usually simple enough to allow multiservice-wide actions by default
46             }
47              
48              
49             1;
50              
51             __END__