Navigation Menu

Skip to content

Commit

Permalink
handle states a little more consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 10, 2016
1 parent 7baa1c0 commit c358417
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/Mojo/Transaction.pm
Expand Up @@ -16,7 +16,7 @@ sub connection {
return $self->{connection};
}

sub delivered { shift->_state(qw(finished finish)) }
sub delivered { shift->_state('finished')->emit('finish') }

sub error { $_[0]->req->error || $_[0]->res->error }

Expand All @@ -38,15 +38,11 @@ sub remote_address {
: $self->original_remote_address;
}

sub resume { shift->_state(qw(write resume)) }
sub resume { shift->_state('write')->emit('resume') }

sub success { $_[0]->error ? undef : $_[0]->res }

sub _state {
my ($self, $state, $event) = @_;
$self->{state} = $state;
return $self->emit($event);
}
sub _state { $_[0]{state} = $_[1] and return $_[0] }

1;

Expand Down

0 comments on commit c358417

Please sign in to comment.