X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FApp%2FClifton%2FService.pm;fp=lib%2FApp%2FClifton%2FService.pm;h=49bb7869be91d48d714cb0261433d77e23df6d8c;hb=327a4b1a20939c6f165dc432ace73d24624047a4;hp=043e877fa5a6c9efef9f16a6a7aeaeb46cc6ccca;hpb=06185cf5ccc6d8e40da2853a8783643ed278cd8f;p=scpubgit%2FClifton.git diff --git a/lib/App/Clifton/Service.pm b/lib/App/Clifton/Service.pm index 043e877..49bb786 100644 --- a/lib/App/Clifton/Service.pm +++ b/lib/App/Clifton/Service.pm @@ -6,17 +6,26 @@ use Moo; extends 'App::Clifton::Component'; sub _do { - my ($self, $do, @args) = @_; + my ($self, $do, $args) = @_; my $body = do { my $body_call = $self->_capture_weakself("_body_for_${do}"); - sub { $body_call->(@args, @_) } + sub { $body_call->(@_) } + }; + my @guard = do { + if ($self->can("_guard_for_${do}")) { + my $guard_call = $self->_capture_weakself("_guard_for_${do}"); + (guard => sub { $guard_call->(@_) }); + } else { + (); + } }; my $deps = {}; if (my $dep_call = $self->can("_dependencies_for_${do}")) { - $deps = $self->$dep_call(@args); + $deps = $self->$dep_call($args); } $self->_new_child(Task, { - name => $do, body => $body, dependencies => $deps + name => $do, body => $body, dependencies => $deps, @guard, + args => $args, }); }