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.59';
3 3     3   63565 use strict;
  3         5  
  3         65  
4 3     3   9 use warnings;
  3         3  
  3         70  
5              
6             # ABSTRACT: simplest multiservice, configured in constructor
7              
8              
9 3     3   796 use Params::Validate qw(:all);
  3         11254  
  3         472  
10 3     3   15 use Scalar::Util qw(blessed);
  3         4  
  3         173  
11 3     3   372 use parent qw(Ubic::Multiservice);
  3         227  
  3         15  
12              
13             sub new {
14 9     9 1 1957 my $class = shift;
15             my ($params) = validate_pos(@_, {
16             type => HASHREF,
17             callbacks => {
18             'values are services' => sub {
19 9     9   32 for (values %{shift()}) {
  9         18  
20 12 100 66     280 return unless blessed($_) and $_->isa('Ubic::Service')
21             }
22 8         26 return 1;
23             },
24             }
25 9         89 });
26 8         42 return bless { services => $params } => $class;
27             }
28              
29             sub has_simple_service($$) {
30 8     8 1 8 my ($self, $name) = @_;
31 8         37 return exists $self->{services}{$name};
32             }
33              
34             sub simple_service($$) {
35 14     14 1 16 my ($self, $name) = @_;
36 14         23 return $self->{services}{$name};
37             }
38              
39             sub service_names($) {
40 3     3 1 4 my $self = shift;
41 3         3 return keys %{ $self->{services} };
  3         17  
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__