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.3520';
5 165     165   1225 use strict;
  165         420  
  165         4856  
6 165     165   863 use warnings;
  165         403  
  165         4538  
7              
8 165     165   914 use base 'Dancer::Object';
  165         383  
  165         56283  
9              
10             Dancer::Hook::Properties->attributes(qw/apps/);
11              
12             sub init {
13 133     133 1 323 my ($self, %args) = @_;
14              
15 133         471 $self->_init_apps(\%args);
16 133         530 return $self;
17             }
18              
19             sub _init_apps {
20 133     133   286 my ( $self, $args ) = @_;
21 133 50       393 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         909 $self->apps( [] );
27             }
28             }
29              
30             sub should_run_this_app {
31 298     298 0 580 my ( $self, $app ) = @_;
32              
33 298 50       444 return 1 unless scalar( @{ $self->apps } );
  298         618  
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__