Skip Menu |

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
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.
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
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