line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Cloudflare::RecordSet; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojo::Cloudflare::RecordSet - A set of Mojo::Cloudflare::Record objects |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
L holds a list of L |
10
|
|
|
|
|
|
|
objects. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
17
|
use Mojo::Base 'Mojo::JSON::Pointer'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
21
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Will be public once I know what to call the attribute |
17
|
|
|
|
|
|
|
has _cf => sub { Mojo::Cloudflare->new }; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 all |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
@records = $self->all; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Returns a list of L objects. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub all { |
30
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return @{ |
33
|
0
|
|
|
|
|
0
|
$self->{all} ||= [ |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
map { |
35
|
0
|
0
|
|
|
|
0
|
my $obj = Mojo::Cloudflare::Record->new($_); |
36
|
0
|
|
|
|
|
0
|
Scalar::Util::weaken($obj->_cf($self->_cf)->{_cf}); |
37
|
0
|
|
|
|
|
0
|
$obj; |
38
|
0
|
|
0
|
|
|
0
|
} @{ $self->get('/objs') || [] } |
39
|
|
|
|
|
|
|
] |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 single |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$record = $self->single(sub { $_->name =~ /^foo/ }); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Used find a single record from L. C is returned |
48
|
|
|
|
|
|
|
if no records match. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
NOTE! This will only return the first record found. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub single { |
55
|
0
|
|
|
0
|
1
|
0
|
my($self, $filter) = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
for($self->all) { |
58
|
0
|
0
|
|
|
|
0
|
next unless $self->$filter; |
59
|
0
|
|
|
|
|
0
|
return $_; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
return undef; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _new_from_tx { |
66
|
1
|
|
|
1
|
|
3
|
my($class, $tx) = @_; |
67
|
1
|
|
|
|
|
5
|
my $err = $tx->error; |
68
|
1
|
|
50
|
|
|
85
|
my $json = $tx->res->json || {}; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
50
|
|
|
3056
|
$json->{result} //= ''; |
71
|
1
|
50
|
0
|
|
|
6
|
$err ||= $json->{msg} || $json->{result} || 'Unknown error.' if $json->{result} ne 'success'; |
|
|
|
0
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
1
|
|
50
|
|
|
11
|
return $err, $class->new($json->{response}{recs} || {}); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Copyright (C) 2014, Jan Henning Thorsen |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
81
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Jan Henning Thorsen - C |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |