rename ok to is_ok and change slot names to avoid conflict with creators

This commit is contained in:
Oliver Gorwits
2017-09-05 19:28:38 +01:00
parent 3ee85383ab
commit fc9c60f707
2 changed files with 14 additions and 13 deletions

View File

@@ -53,7 +53,7 @@ sub _run_first {
}; };
$retval ||= Status->done('no status supplied'); $retval ||= Status->done('no status supplied');
return $retval if $retval->ok; return $retval if $retval->is_ok;
} }
return Status->error('no worker was successful'); return Status->error('no worker was successful');

View File

@@ -7,9 +7,9 @@ use Moo;
use namespace::clean; use namespace::clean;
foreach my $slot (qw/ foreach my $slot (qw/
done done_slot
error error_slot
defer defer_slot
/) { /) {
has $slot => ( has $slot => (
@@ -31,17 +31,18 @@ Shorthand for new() with setting param, accepts log as arg.
=cut =cut
sub done { return (shift)->new({done => 1, log => shift}) } sub done { return (shift)->new({done_slot => 1, log => shift}) }
sub error { return (shift)->new({error => 1, log => shift}) } sub error { return (shift)->new({error_slot => 1, log => shift}) }
sub defer { return (shift)->new({defer => 1, log => shift}) } sub defer { return (shift)->new({defer_slot => 1, log => shift}) }
=head2 ok =head2 is_ok
Returns true if C<done> is true and C<error> and C<defer> have not been set. Returns true if C<done> is true and C<error> and C<defer> have not been set.
=cut =cut
sub ok { return ($_[0]->done and not $_[0]->error and not $_[0]->defer) } sub is_ok { return ($_[0]->done_slot
and not $_[0]->error_slot and not $_[0]->defer_slot) }
=head2 not_ok =head2 not_ok
@@ -49,7 +50,7 @@ Returns the logical inversion of C<ok>.
=cut =cut
sub not_ok { return (not $_[0]->ok) } sub not_ok { return (not $_[0]->is_ok) }
=head2 status =head2 status
@@ -60,9 +61,9 @@ Returns text equivalent of C<done>, C<defer>, or C<error>.
sub status { sub status {
my $self = shift; my $self = shift;
return ( return (
$self->done ? 'done' $self->done_slot ? 'done'
: $self->defer ? 'defer' : $self->defer_slot ? 'defer'
: 'error'; : 'error';
); );
} }