File Coverage

blib/lib/Dancer/Hook/Properties.pm
Criterion Covered Total %
statement 18 24 75.0
branch 2 8 25.0
condition n/a
subroutine 6 6 100.0
pod 1 2 50.0
total 27 40 67.5


line stmt bran cond sub pod time code
1             package Dancer::Hook::Properties;
2             our $AUTHORITY = 'cpan:SUKRIA';
3             #ABSTRACT: Properties attached to a hook
4             $Dancer::Hook::Properties::VERSION = '1.3521';
5 165     165   1139 use strict;
  165         378  
  165         4709  
6 165     165   928 use warnings;
  165         403  
  165         4508  
7              
8 165     165   860 use base 'Dancer::Object';
  165         444  
  165         54452  
9              
10             Dancer::Hook::Properties->attributes(qw/apps/);
11              
12             sub init {
13 133     133 1 342 my ($self, %args) = @_;
14              
15 133         455 $self->_init_apps(\%args);
16 133         472 return $self;
17             }
18              
19             sub _init_apps {
20 133     133   285 my ( $self, $args ) = @_;
21 133 50       388 if ( my $apps = $args->{'apps'} ) {
22 0 0       0 ref $apps ? $self->apps($apps) : $self->apps( [$apps] );
23 0         0 return;
24             }
25             else {
26 133         944 $self->apps( [] );
27             }
28             }
29              
30             sub should_run_this_app {
31 298     298 0 598 my ( $self, $app ) = @_;
32              
33 298 50       436 return 1 unless scalar( @{ $self->apps } );
  298         627  
34              
35 0 0         if ( $self->apps ) {
36 0           return grep { $_ eq $app } @{ $self->apps };
  0            
  0            
37             }
38             }
39              
40             1;
41              
42             __END__