line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OperaLink::Datatype; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
408
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my ($class, $id) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
0
|
|
|
|
$class = ref $class || $class; |
12
|
|
|
|
|
|
|
|
13
|
0
|
0
|
0
|
|
|
|
if (not defined $id or not $id) { |
14
|
0
|
|
|
|
|
|
Carp::croak "Missing '$_'. Can't instance $class\n"; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $self = { |
18
|
|
|
|
|
|
|
_id => $id, |
19
|
|
|
|
|
|
|
_loaded => 0, |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
bless $self, $class; |
23
|
0
|
|
|
|
|
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub datatype_url_root { |
27
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
28
|
0
|
|
0
|
|
|
|
my $class = ref $self || $self; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my @namespace = split '::', $class; |
31
|
0
|
|
|
|
|
|
$class = lc pop @namespace; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub api_url_for { |
37
|
0
|
|
|
0
|
0
|
|
my ($self, $type) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $dt_url = $self->datatype_url_root(); |
40
|
0
|
|
|
|
|
|
my $url; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if (not defined $type) { |
43
|
0
|
|
|
|
|
|
return; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
0
|
|
|
|
if ($type eq 'children' or $type eq 'descendants') { |
47
|
0
|
|
|
|
|
|
$url = "$dt_url/$type"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
0
|
|
|
|
|
|
my $id = $type; |
51
|
0
|
|
|
|
|
|
$url = "$dt_url/$id"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $url; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub get { |
58
|
0
|
|
|
0
|
0
|
|
my ($self, @args) = @_; |
59
|
0
|
|
|
|
|
|
my $api_url = $self->url_for(@args); |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if (not $api_url) { |
62
|
0
|
|
|
|
|
|
Carp::croak("Don't know where to get this resource (@args)"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|