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
|
|
751
|
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
|
|
|
|
|
|
|
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.02 |
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 |