blib/lib/OAuthomatic/Internal/UsageGuard.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 34 CC 3 SCAR 14.6
CC
3
Cov
0%
prepare
6.0
finish
6.0
DEMOLISH
2.0
CRAP 4.3
1 package OAuthomatic::Internal::UsageGuard;
2 # ABSTRACT: support for RAII for some roles
3  
4  
5 use Moose;
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 return;
17 }
18  
19 sub finish {
20 my $self = shift;
21 return unless $self->_active;
22 $self->obj->cleanup_after_work;
23 $self->_active(0);
24 return;
25 }
26  
27 sub DEMOLISH {
28 my $self = shift;
29 $self->finish;
30 return;
31 }
32  
33 1;
34  
35 __END__
36  
37 =pod
38  
39 =encoding UTF-8
40  
41 =head1 NAME
42  
43 OAuthomatic::Internal::UsageGuard - support for RAII for some roles
44  
45 =head1 VERSION
46  
47 version 0.0201
48  
49 =head1 DESCRIPTION
50  
51 Internally used by L<OAuthomatic>
52  
53 =head1 AUTHOR
54  
55 Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
56  
57 =head1 COPYRIGHT AND LICENSE
58  
59 This software is copyright (c) 2015 by Marcin Kasperski.
60  
61 This is free software; you can redistribute it and/or modify it under
62 the same terms as the Perl 5 programming language system itself.
63  
64 =cut