| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Flickr::Tools::Reflection; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22871
|
use Flickr::API::Reflection; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Types::Standard qw ( InstanceOf ); |
|
5
|
|
|
|
|
|
|
use Carp; |
|
6
|
|
|
|
|
|
|
use Moo; |
|
7
|
|
|
|
|
|
|
use strictures; |
|
8
|
|
|
|
|
|
|
use namespace::clean; |
|
9
|
|
|
|
|
|
|
use 5.010; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with qw(Flickr::Roles::Caching); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.22'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends 'Flickr::Tools'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '+_api_name' => ( |
|
18
|
|
|
|
|
|
|
is => 'ro', |
|
19
|
|
|
|
|
|
|
isa => sub { $_[0] eq 'Flickr::API::Reflection' }, |
|
20
|
|
|
|
|
|
|
required => 1, |
|
21
|
|
|
|
|
|
|
default => 'Flickr::API::Reflection', |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub getMethods { |
|
25
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
26
|
|
|
|
|
|
|
my $methods; |
|
27
|
|
|
|
|
|
|
my $pre_expire = 0; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$self->_set_cache_hit(1); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
if ( defined( $args->{clear_cache} ) and $args->{clear_cache} ) { |
|
32
|
|
|
|
|
|
|
$pre_expire = 1; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if (defined($args->{list_type}) and $args->{list_type} =~ m/list/i) { |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->_set_cache_key('methods_list'); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$methods = $self->_cache->get( $self->cache_key, |
|
40
|
|
|
|
|
|
|
expire_if => sub { $pre_expire } ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
if ( !defined $methods ) { |
|
43
|
|
|
|
|
|
|
$methods = $self->{_api}->methods_list; |
|
44
|
|
|
|
|
|
|
$self->_set_cache_hit(0); |
|
45
|
|
|
|
|
|
|
$self->_cache->set( $self->cache_key, $methods, |
|
46
|
|
|
|
|
|
|
$self->cache_duration ); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
else { |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->_set_cache_key('methods_hash'); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$methods = $self->_cache->get( $self->cache_key, |
|
54
|
|
|
|
|
|
|
expire_if => sub { $pre_expire } ); |
|
55
|
|
|
|
|
|
|
if ( !defined $methods) { |
|
56
|
|
|
|
|
|
|
$methods = $self->{_api}->methods_hash; |
|
57
|
|
|
|
|
|
|
$self->_set_cache_hit(0); |
|
58
|
|
|
|
|
|
|
$self->_cache->set( $self->cache_key, $methods, |
|
59
|
|
|
|
|
|
|
$self->cache_duration ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $methods; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub getMethod { |
|
68
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
69
|
|
|
|
|
|
|
my $rsp = {}; |
|
70
|
|
|
|
|
|
|
my $pre_expire = 0; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$self->_set_cache_hit(1); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
if ($args =~ m/flickr\.[a-z]+\.*/x) { |
|
75
|
|
|
|
|
|
|
my $tmp = { Method => $args }; |
|
76
|
|
|
|
|
|
|
$args = $tmp; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
if ( defined( $args->{clear_cache} ) and $args->{clear_cache} ) { |
|
79
|
|
|
|
|
|
|
$pre_expire = 1; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
if (exists($args->{Method})) { |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->_set_cache_key( 'Method ' . $args->{Method} ); |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$rsp = $self->_cache->get( $self->cache_key, |
|
87
|
|
|
|
|
|
|
expire_if => sub { $pre_expire } ); |
|
88
|
|
|
|
|
|
|
if ( !defined $rsp) { |
|
89
|
|
|
|
|
|
|
$rsp = $self->{_api}->get_method($args->{Method}); |
|
90
|
|
|
|
|
|
|
$self->_set_cache_hit(0); |
|
91
|
|
|
|
|
|
|
$self->_cache->set( $self->cache_key, $rsp, |
|
92
|
|
|
|
|
|
|
$self->cache_duration ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
else { |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
carp 'argument neither a hashref pointing to a method, or the name of a method'; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
return $rsp; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |