line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Snoo::Comment; |
2
|
5
|
|
|
5
|
|
27
|
use Moo; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
36
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
extends 'Mojo::Snoo::Base'; |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
1359
|
use constant FIELD => 'id'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
1300
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has id => ( |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
isa => sub { |
11
|
|
|
|
|
|
|
die "Comment needs ID!" unless $_[0]; |
12
|
|
|
|
|
|
|
}, |
13
|
|
|
|
|
|
|
required => 1 |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has [qw( author body )] => (is => 'ro'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has replies => ( |
19
|
|
|
|
|
|
|
is => 'rw', |
20
|
|
|
|
|
|
|
coerce => sub { |
21
|
|
|
|
|
|
|
my $replies = shift; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# comments without replies contain " " |
24
|
|
|
|
|
|
|
my $children = ref($replies) ? $replies->{data}{children} : []; |
25
|
|
|
|
|
|
|
return Mojo::Collection->new( |
26
|
|
|
|
|
|
|
map { |
27
|
|
|
|
|
|
|
$_->{kind} eq 't1' # unloaded comments have type 'more' |
28
|
|
|
|
|
|
|
? Mojo::Snoo::Comment->new(%{$_->{data}}) |
29
|
|
|
|
|
|
|
: () |
30
|
|
|
|
|
|
|
} @$children |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# let the user call the constructor using new($comment) or new(id => $comment) |
36
|
1
|
50
|
|
1
|
0
|
2144
|
sub BUILDARGS { shift->SUPER::BUILDARGS(@_ == 1 ? (id => shift) : @_) } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |