File Coverage

lib/OAuthomatic/Internal/UsageGuard.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package OAuthomatic::Internal::UsageGuard;
2             # ABSTRACT: support for RAII for some roles
3              
4              
5 1     1   1003 use Moose;
  0            
  0            
6             use namespace::sweep;
7              
8             has 'obj' => (is => 'ro', isa=>'Object');
9             has '_active' => (is=>'rw', isa=>'Bool');
10              
11             sub prepare {
12             my $self = shift;
13             return if $self->_active;
14             $self->obj->prepare_to_work;
15             $self->_active(1);
16             }
17              
18             sub finish {
19             my $self = shift;
20             return unless $self->_active;
21             $self->obj->cleanup_after_work;
22             $self->_active(0)
23             }
24              
25             sub DEMOLISH {
26             my $self = shift;
27             $self->finish;
28             }
29              
30             1;
31              
32             __END__
33              
34             =pod
35              
36             =encoding UTF-8
37              
38             =head1 NAME
39              
40             OAuthomatic::Internal::UsageGuard - support for RAII for some roles
41              
42             =head1 VERSION
43              
44             version 0.01
45              
46             =head1 DESCRIPTION
47              
48             Internally used by L<OAuthomatic>
49              
50             =head1 AUTHOR
51              
52             Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
53              
54             =head1 COPYRIGHT AND LICENSE
55              
56             This software is copyright (c) 2015 by Marcin Kasperski.
57              
58             This is free software; you can redistribute it and/or modify it under
59             the same terms as the Perl 5 programming language system itself.
60              
61             =cut