line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Dynect::REST::Response::Data; |
2
|
|
|
|
|
|
|
# $Id: Data.pm 177 2010-09-28 00:50:02Z james $ |
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
4
|
use overload '""' => \&_as_string; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
49
|
use Carp; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
361
|
|
7
|
|
|
|
|
|
|
our $AUTOLOAD; |
8
|
|
|
|
|
|
|
our $VERSION = do { my @r = (q$Revision: 177 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Net::Dynect::REST::Response::Data - Data object returned as a result of a request |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Net::Dynect::REST::Response::Data; |
17
|
|
|
|
|
|
|
my $data = Net::Dynect::REST::Response::Data->new(data => $hashref); |
18
|
|
|
|
|
|
|
my @keys = $data->data_keys; |
19
|
|
|
|
|
|
|
print $data->some_key; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 Creating |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item new |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This constructor takes the data as decoded from the response. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=back |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
1
|
|
|
1
|
1
|
2
|
my $proto = shift; |
37
|
1
|
|
33
|
|
|
11
|
my $self = bless {}, ref($proto) || $proto; |
38
|
1
|
|
|
|
|
4
|
my %args = @_; |
39
|
1
|
50
|
|
|
|
5
|
$self->{data} = $args{data} if defined $args{data}; |
40
|
1
|
|
|
|
|
9
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _data { |
44
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
45
|
0
|
0
|
|
|
|
0
|
if (@_) { |
46
|
0
|
|
|
|
|
0
|
my $new = shift; |
47
|
0
|
|
|
|
|
0
|
$self->{data} = $new; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
0
|
return $self->{data}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 Attributes |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item data_keys |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This returns the names of the keys of the data returned. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item other, random, names |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
As the data varies depending on the request given, so does the value returned in the response. Hence the data may have a key of B, or B, or anthing else. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub data_keys { |
67
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
68
|
0
|
|
|
|
|
0
|
return keys %{ $self->{data} }; |
|
0
|
|
|
|
|
0
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub AUTOLOAD { |
72
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
73
|
0
|
0
|
|
|
|
0
|
if ( ref($self) ne "Net::Dynect::REST::Response::Data" ) { |
74
|
0
|
|
|
|
|
0
|
carp "This should be a Net::Dynect::REST::Response::Data"; |
75
|
0
|
|
|
|
|
0
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
|
|
0
|
my $name = $AUTOLOAD; |
78
|
0
|
0
|
|
|
|
0
|
return unless defined $self->{data}; |
79
|
0
|
|
|
|
|
0
|
$name =~ s/.*://; # strip fully-qualified portion |
80
|
0
|
0
|
|
|
|
0
|
return $self->{data}->{$name} if defined $self->{data}->{$name}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _as_string { |
84
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
85
|
1
|
|
|
1
|
|
3413
|
use Data::Dumper; |
|
1
|
|
|
|
|
11320
|
|
|
1
|
|
|
|
|
122
|
|
86
|
1
|
|
|
|
|
2
|
$Data::Dumper::Terse = 1; |
87
|
1
|
|
|
|
|
9
|
return Dumper $self->{data}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L, L, L. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
James bromberger, james@rcpt.to |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright (C) 2010 by James Bromberger |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
105
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.1 or, |
106
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |