| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: Stub.pm 7370 2012-04-09 01:17:33Z chris $ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
WebService::IMDB::Title::Stub |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
WebService::IMDB::Title::Stub is to store any data supplied alongside |
|
10
|
|
|
|
|
|
|
a reference to a title, preventing additional API requests. WebService::IMDB::Title::Stub |
|
11
|
|
|
|
|
|
|
isa WebService::IMDB::Title, and can be treated as such. Any of the methods specific to |
|
12
|
|
|
|
|
|
|
WebService::IMDB::Title::Stub can be called with a single true argument, preventing |
|
13
|
|
|
|
|
|
|
recursion to WebService::IMDB::Title if the data isn't immediately available. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package WebService::IMDB::Title::Stub; |
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
69
|
|
|
20
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
100
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
11
|
use base qw(WebService::IMDB::Title); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
164
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
145
|
|
|
27
|
|
|
|
|
|
|
our @CARP_NOT = qw(WebService::IMDB WebService::IMDB::Name); |
|
28
|
|
|
|
|
|
|
|
|
29
|
2
|
|
|
2
|
|
12
|
use WebService::IMDB::Title; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
29
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( |
|
32
|
|
|
|
|
|
|
_stub_tconst |
|
33
|
|
|
|
|
|
|
_stub_image |
|
34
|
|
|
|
|
|
|
_stub_release_date |
|
35
|
|
|
|
|
|
|
_stub_title |
|
36
|
|
|
|
|
|
|
_stub_type |
|
37
|
|
|
|
|
|
|
_stub_year |
|
38
|
|
|
|
|
|
|
)); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 obj |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Return a conventional WebService::IMDB::Title object. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 tconst |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 release_date |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 title |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 type |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 year |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _new { |
|
60
|
356
|
|
|
356
|
|
481
|
my $class = shift; |
|
61
|
356
|
|
|
|
|
405
|
my $ws = shift; |
|
62
|
356
|
|
|
|
|
373
|
my $data = shift; |
|
63
|
|
|
|
|
|
|
|
|
64
|
356
|
|
|
|
|
1973
|
my $self = $class->SUPER::_new($ws, {'tconst' => $data->{'tconst'}}, '_defer_fetch' => 1); |
|
65
|
356
|
|
|
|
|
874
|
bless $self, $class; |
|
66
|
|
|
|
|
|
|
|
|
67
|
356
|
|
|
|
|
1093
|
$self->_stub_tconst($data->{'tconst'}); |
|
68
|
356
|
100
|
|
|
|
4122
|
if (exists $data->{'image'}) { $self->_stub_image(WebService::IMDB::Image->_new($ws, $data->{'image'})); } |
|
|
262
|
|
|
|
|
1121
|
|
|
69
|
356
|
100
|
|
|
|
2894
|
if (exists $data->{'release_date'}) { $self->_stub_release_date(WebService::IMDB::Date->_new($ws, $data->{'release_date'})); } |
|
|
65
|
|
|
|
|
350
|
|
|
70
|
356
|
50
|
|
|
|
2929
|
if (exists $data->{'title'}) { $self->_stub_title($data->{'title'}); } # TODO: This should perhaps be treated as non-optional |
|
|
356
|
|
|
|
|
1235
|
|
|
71
|
356
|
50
|
|
|
|
4943
|
if (exists $data->{'type'}) { $self->_stub_type($data->{'type'}); } |
|
|
356
|
|
|
|
|
1100
|
|
|
72
|
356
|
50
|
|
|
|
3681
|
if (exists $data->{'year'}) { $self->_stub_year($data->{'year'}); } |
|
|
356
|
|
|
|
|
985
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
356
|
|
|
|
|
4009
|
if (0) { $self->_check_unparsed($data); } |
|
75
|
|
|
|
|
|
|
|
|
76
|
356
|
|
|
|
|
1507
|
return $self; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub obj { |
|
80
|
1
|
|
|
1
|
1
|
15
|
my $self = shift; |
|
81
|
1
|
|
|
|
|
7
|
return WebService::IMDB::Title->_new($self->_ws(), {'tconst' => $self->tconst()}); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub tconst { |
|
85
|
3
|
|
|
3
|
1
|
34
|
my $self = shift; |
|
86
|
3
|
|
|
|
|
13
|
return $self->_stub_tconst(); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub image { |
|
90
|
1
|
|
|
1
|
1
|
18
|
my $self = shift; |
|
91
|
1
|
|
|
|
|
2
|
my $nosuper = shift; |
|
92
|
|
|
|
|
|
|
|
|
93
|
1
|
50
|
|
|
|
6
|
if (defined $self->_stub_image()) { |
|
|
|
0
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
16
|
return $self->_stub_image(); |
|
95
|
|
|
|
|
|
|
} elsif ($nosuper) { |
|
96
|
0
|
|
|
|
|
0
|
return undef; |
|
97
|
|
|
|
|
|
|
} else { |
|
98
|
0
|
|
|
|
|
0
|
return $self->SUPER::image(); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub release_date { |
|
103
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
104
|
0
|
|
|
|
|
0
|
my $nosuper = shift; |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
0
|
if (defined $self->_stub_release_date()) { |
|
|
|
0
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
return $self->_stub_release_date(); |
|
108
|
|
|
|
|
|
|
} elsif ($nosuper) { |
|
109
|
0
|
|
|
|
|
0
|
return undef; |
|
110
|
|
|
|
|
|
|
} else { |
|
111
|
0
|
|
|
|
|
0
|
return $self->SUPER::release_date(); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub title { |
|
116
|
1
|
|
|
1
|
1
|
17
|
my $self = shift; |
|
117
|
1
|
|
|
|
|
3
|
my $nosuper = shift; |
|
118
|
|
|
|
|
|
|
|
|
119
|
1
|
50
|
|
|
|
6
|
if (defined $self->_stub_title()) { |
|
|
|
0
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
15
|
return $self->_stub_title(); |
|
121
|
|
|
|
|
|
|
} elsif ($nosuper) { |
|
122
|
0
|
|
|
|
|
|
return undef; |
|
123
|
|
|
|
|
|
|
} else { |
|
124
|
0
|
|
|
|
|
|
return $self->SUPER::title(); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub type { |
|
129
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
130
|
0
|
|
|
|
|
|
my $nosuper = shift; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
if (defined $self->_stub_type()) { |
|
|
|
0
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
return $self->_stub_type(); |
|
134
|
|
|
|
|
|
|
} elsif ($nosuper) { |
|
135
|
0
|
|
|
|
|
|
return undef; |
|
136
|
|
|
|
|
|
|
} else { |
|
137
|
0
|
|
|
|
|
|
return $self->SUPER::type(); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub year { |
|
142
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
143
|
0
|
|
|
|
|
|
my $nosuper = shift; |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
if (defined $self->_stub_year()) { |
|
|
|
0
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
return $self->_stub_year(); |
|
147
|
|
|
|
|
|
|
} elsif ($nosuper) { |
|
148
|
0
|
|
|
|
|
|
return undef; |
|
149
|
|
|
|
|
|
|
} else { |
|
150
|
0
|
|
|
|
|
|
return $self->SUPER::year(); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub _check_unparsed { |
|
156
|
2
|
|
|
2
|
|
1435
|
use Storable qw(dclone); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
331
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
159
|
0
|
|
|
|
|
|
my $d = dclone(shift); |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
delete $d->{'tconst'}; |
|
162
|
0
|
|
|
|
|
|
delete $d->{'image'}; |
|
163
|
0
|
|
|
|
|
|
delete $d->{'title'}; |
|
164
|
0
|
|
|
|
|
|
delete $d->{'type'}; |
|
165
|
0
|
|
|
|
|
|
delete $d->{'year'}; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
if (scalar keys %$d != 0) { |
|
168
|
0
|
|
|
|
|
|
die "Remaining keys: " . join(", ", keys %$d); |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |