X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTak%2FResult.pm;h=38d5e59db087f8601284996f9e627d06014d0b84;hb=2791fd73b196072f047b2b3d746b64be53312ca3;hp=a7afb4f554a13266c3240fe6659d78d9a0e491c9;hpb=31a246e4b1ef71cc1991c1631573f6c80cdf41b5;p=scpubgit%2FTak.git diff --git a/lib/Tak/Result.pm b/lib/Tak/Result.pm index a7afb4f..38d5e59 100644 --- a/lib/Tak/Result.pm +++ b/lib/Tak/Result.pm @@ -5,9 +5,13 @@ use Moo; has type => (is => 'ro', required => 1); has data => (is => 'ro', required => 1); +sub flatten { $_[0]->type, @{$_[0]->data} } + +sub is_success { $_[0]->type eq 'success' } + sub get { my ($self) = @_; - $self->throw unless $self->type eq 'success'; + $self->throw unless $self->is_success; return wantarray ? @{$self->data} : $self->data->[0]; }