package DX::Role::Action;

use Moo::Role;

has id => (is => 'ro');

has dependencies => (is => 'ro', default => sub { [] });

has was_run => (is => 'rw');

requires 'expected_effect';
requires '_do_run';

sub but { my ($self, @but) = @_; ref($self)->new(%$self, @but); }

sub run {
  my ($self) = @_;
  die "Can't run, was already run" if $self->was_run;
  my @res = $self->_do_run;
  $self->was_run(1);
  return @res;
}

1;
