line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Role::Actions; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1781
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
63
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
478
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Class::Load qw(); |
9
|
|
|
|
|
|
|
use Games::Lacuna::Task::Utils qw(class_to_name); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Module::Pluggable |
12
|
|
|
|
|
|
|
search_path => ['Games::Lacuna::Task::Action'], |
13
|
|
|
|
|
|
|
sub_name => '_all_actions'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ALL_ACTIONS; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load_action { |
18
|
|
|
|
|
|
|
my ($self,$action_class) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $action_name = class_to_name($action_class); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my ($ok,$error) = Class::Load::try_load_class($action_class); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
if (! $ok) { |
25
|
|
|
|
|
|
|
return (0,sprintf("Could not load task '%s': %s",$action_name,$error)); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $action_class_meta = $action_class->meta; |
29
|
|
|
|
|
|
|
if ($action_class_meta->can('deprecated')) { |
30
|
|
|
|
|
|
|
return (0,sprintf("Task '%s' is deprecated",$action_name)); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return (1,undef); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub all_actions { |
37
|
|
|
|
|
|
|
my ($self) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return @ALL_ACTIONS |
40
|
|
|
|
|
|
|
if scalar @ALL_ACTIONS; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
@ALL_ACTIONS = _all_actions(); |
43
|
|
|
|
|
|
|
return @ALL_ACTIONS; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |