Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

This queue is for tickets about the future CPAN distribution.

Report information
The Basics
Id: 120759
Status: resolved
Priority: 0/
Queue: future

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.34
Fixed in: 0.36



Subject: Method returning current state as a string
Download (untitled) / with headers
text/plain 396b
I find myself writing the equivalent of this in most projects: sub status { $_[0]->is_done ? 'done' : $_[0]->is_failed ? 'failed' : $_[0]->is_cancelled ? 'cancelled' : 'pending' } sub describe { ($_[0]->label // 'Future') . '(' . $_[0]->status . ')' } Would be nice to have something along these lines as a standard method.
Download (untitled) / with headers
text/plain 530b
On Sun Mar 26 04:07:39 2017, TEAM wrote: Show quoted text
> I find myself writing the equivalent of this in most projects: > > sub status { > $_[0]->is_done > ? 'done' > : $_[0]->is_failed > ? 'failed' > : $_[0]->is_cancelled > ? 'cancelled' > : 'pending' > }
There actually already is an internal ->_state method so should be trivial just to expose that as API instead. Show quoted text
> sub describe { ($_[0]->label // 'Future') . '(' . $_[0]->status . ')' }
Looks good. -- Paul Evans
Download (untitled) / with headers
text/plain 198b
On Sun Mar 26 04:07:39 2017, TEAM wrote: Show quoted text
> Would be nice to have something along these lines as a standard method.
This was added in 0.36. https://metacpan.org/pod/Future#state -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.