| 1 | |||
| 2 | use v5.14; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | use Syntax::Construct qw (package-block package-version); | ||
| 6 | |||
| 7 | package Test::YAFT::Act v1.0.4 { | ||
| 8 | use Ref::Util (); | ||
| 9 | |||
| 10 | use Test::YAFT::Act::Context; | ||
| 11 | |||
| 12 | sub new { | ||
| 13 | my ($class, $act, @args) = @_; | ||
| 14 | |||
| 15 | my $dispatch_type = ref ($args[0]) | ||
| 16 | ? shift @args | ||
| 17 | : [ ] | ||
| 18 | ; | ||
| 19 | |||
| 20 | $dispatch_type = Ref::Util::is_hashref ($dispatch_type) | ||
| 21 | ? Test::YAFT::Act::Context::DISPATCH_HASH | ||
| 22 | : Test::YAFT::Act::Context::DISPATCH_ARRAY | ||
| 23 | ; | ||
| 24 | |||
| 25 | my (@dependencies, %options); | ||
| 26 | while (@args) { | ||
| 27 | push @dependencies, my $dependency = shift @args; | ||
| 28 | |||
| 29 | $options{$dependency} = shift @args | ||
| 30 | if ref $args[0] | ||
| 31 | ; | ||
| 32 | } | ||
| 33 | |||
| 34 | return bless { | ||
| 35 | act => $act, | ||
| 36 | dependencies => \ @dependencies, | ||
| 37 | dispatch_type => $dispatch_type, | ||
| 38 | options => \ %options, | ||
| 39 | }, $class; | ||
| 40 | } | ||
| 41 | |||
| 42 | sub act { | ||
| 43 | $_[0]->{act}; | ||
| 44 | } | ||
| 45 | |||
| 46 | sub context { | ||
| 47 | Test::YAFT::Act::Context::->new ($_[0]); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub dependencies { | ||
| 51 | @{ $_[0]->{dependencies} } | ||
| 52 | } | ||
| 53 | |||
| 54 | sub options { | ||
| 55 | $_[0]->{options} | ||
| 56 | } | ||
| 57 | |||
| 58 | 1; | ||
| 59 | }; | ||
| 60 | |||
| 61 | __END__ |