don't screw up on messages with no target_name in hints
[scpubgit/Clifton.git] / lib / App / Clifton / Service.pm
CommitLineData
20038dd8 1package App::Clifton::Service;
2
3use aliased 'App::Clifton::Task';
4use Moo;
5
6extends 'App::Clifton::Component';
7
8sub _do {
327a4b1a 9 my ($self, $do, $args) = @_;
20038dd8 10 my $body = do {
11 my $body_call = $self->_capture_weakself("_body_for_${do}");
327a4b1a 12 sub { $body_call->(@_) }
13 };
14 my @guard = do {
15 if ($self->can("_guard_for_${do}")) {
16 my $guard_call = $self->_capture_weakself("_guard_for_${do}");
17 (guard => sub { $guard_call->(@_) });
18 } else {
19 ();
20 }
20038dd8 21 };
22 my $deps = {};
38180dc8 23 $args ||= {};
20038dd8 24 if (my $dep_call = $self->can("_dependencies_for_${do}")) {
327a4b1a 25 $deps = $self->$dep_call($args);
20038dd8 26 }
27 $self->_new_child(Task, {
327a4b1a 28 name => $do, body => $body, dependencies => $deps, @guard,
29 args => $args,
20038dd8 30 });
31}
32
331;