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