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

filter: Statementstmt 0.0% 0 / 19 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 / 31 SCAR 24.8
CC
3
Cov
0%
prepare
6.0
finish
6.0
DEMOLISH
2.0
CRAP 12.0
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 }
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