| 1 | package BioX::Workflow::Command::run::Rules::Directives::Interpolate; | ||
| 2 | |||
| 3 | use Moose::Role; | ||
| 4 | use namespace::autoclean; | ||
| 5 | |||
| 6 | use Moose::Util qw/apply_all_roles/; | ||
| 7 | |||
| 8 | use Try::Tiny; | ||
| 9 | |||
| 10 | has 'interpol_directive_cache' => ( | ||
| 11 | is => 'rw', | ||
| 12 | isa => 'HashRef', | ||
| 13 | default => sub { {} }, | ||
| 14 | ); | ||
| 15 | |||
| 16 | #TODO This should not be here | ||
| 17 | has 'before_meta' => ( | ||
| 18 | traits => ['String'], | ||
| 19 | is => 'rw', | ||
| 20 | isa => 'Str', | ||
| 21 | default => q{}, | ||
| 22 | predicate => 'has_before_meta', | ||
| 23 | required => 0, | ||
| 24 | handles => { | ||
| 25 | add_before_meta => 'append', | ||
| 26 | replace_before_meta => 'replace', | ||
| 27 | }, | ||
| 28 | ); | ||
| 29 | |||
| 30 | sub apply_interpolate_role { | ||
| 31 | my $self = shift; | ||
| 32 | |||
| 33 | # return if $self->can('interpol_directive'); | ||
| 34 | |||
| 35 | my $role = 'BioX::Workflow::Command::run::Rules::Directives::Interpolate::'.$self->template_type; | ||
| 36 | try { | ||
| 37 | apply_all_roles( $self, $role ); | ||
| 38 | } | ||
| 39 | catch { | ||
| 40 | $self->app_log->warn( 'There was an error registering Template role ' . $role ); | ||
| 41 | $self->app_log->warn( $@ . "\n" ); | ||
| 42 | }; | ||
| 43 | } | ||
| 44 | |||
| 45 | # no Moose; | ||
| 46 | |||
| 47 | 1; |