File Coverage

blib/lib/AnyEvent/Inotify/EventReceiver/Callback.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod n/a
total 18 18 100.0


line stmt bran cond sub pod time code
1             package AnyEvent::Inotify::EventReceiver::Callback;
2             $AnyEvent::Inotify::EventReceiver::Callback::VERSION = '0.04';
3 3     3   24 use Moose;
  3         21  
  3         27  
4             #use namespace::autoclean;
5              
6 3     3   20110 use MooseX::Types::Moose qw(CodeRef);
  3         9  
  3         29  
7              
8             has 'callback' => (
9             traits => ['Code'],
10             is => 'ro',
11             isa => CodeRef,
12             required => 1,
13             handles => {
14             call_callback => 'execute',
15             },
16             );
17              
18             for my $event (qw/access modify attribute_change close open move delete create/){
19             __PACKAGE__->meta->add_method( "handle_$event" => sub {
20 23     23   303 my $self = shift;
        23      
        23      
        23      
        23      
        23      
        23      
        23      
21 23         1073 $self->call_callback($event, @_);
22             });
23             }
24              
25             with 'AnyEvent::Inotify::EventReceiver';
26              
27             1;
28              
29             __END__
30              
31             =head1 NAME
32              
33             AnyEvent::Inotify::EventReceiver::Callback - delegates everything to a coderef
34              
35             =head1 ABSTRACT
36              
37             =head1 INITARGS
38              
39             =head2 callback
40              
41             Coderef to be called when an event is received.
42              
43             =head1 DESCRIPTION
44              
45             This EventReceiver delegates every event to the C<callback> coderef.
46             The coderef gets the name of the event being delegated (access,
47             modify, attribute_change, ...) and the args that that event handler
48             would normally get.