package MooseX::Workers::Job;
use strict;
use Moose;
use MooseX::Storage;
use Data::UUID;

with Storage( format => 'JSON' );

use overload (
    '""'  => sub { $_[0]->uuid },
    '&{}' => sub {
        my $self = shift;
        sub { $self->run }
    },
);

has uuid => (
    isa       => 'Str',
    is        => 'ro',
    lazy      => 1,
    required  => 1,
    default   => sub { Data::UUID->new()->create_str() },
);

has command => (
    metaclass => 'DoNotSerialize',
    isa       => 'Defined',
    is        => 'rw',
    required  => 1,
    default   => sub { sub { confess "No command given" } },
);

has args => (
    metaclass => 'DoNotSerialize',
    isa       => 'ArrayRef',
    is        => 'rw',
    required  => 1,
    default   => sub { [] },
);

no Moose;  # unimport Moose's keywords so they won't accidentally become methods
1;         # Magic true value required at end of module
__END__
