File Coverage

blib/lib/WebService/Mattermost/V4/API/Object/Thread.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 2 0.0
condition n/a
subroutine 3 6 50.0
pod n/a
total 12 28 42.8


line stmt bran cond sub pod time code
1             package WebService::Mattermost::V4::API::Object::Thread;
2:

3: # ABSTRACT: A message thread. 4:
5: use Moo;
6: use Types::Standard qw(ArrayRef Maybe);
7:
8: use WebService::Mattermost::V4::API::Object::Post;
9:
10: extends 'WebService::Mattermost::V4::API::Object';
11:
12: ################################################################################
13:
14: has [ qw(
15: order
16: matches
17: posts
18: ) ] => (is => 'ro', isa => Maybe[ArrayRef], lazy => 1, builder => 1);
19:
20: ################################################################################
21:
22: sub _build_order { shift->raw_data->{order} }
23: sub _build_matches { shift->raw_data->{matches} }
24:
25: sub _build_posts {
26: my $self = shift;
27:
28: my @posts;
29:
30: foreach my $post (keys %{$self->raw_data->{posts}}) {
31: push @posts, WebService::Mattermost::V4::API::Object::Post
32: ->new($self->_related_args($self->raw_data->{posts}->{$post}));
33: }
34:
35: if (scalar @posts) {
36: @posts = sort { $a->create_at <=> $b->create_at } @posts;
37: }
38:
39: return \@posts;
40: }
41:
42: ################################################################################
43:
44: 1;
45:
46: __END__
47:
48: =pod
49:
50: =encoding UTF-8
51:
52: =head1 NAME
53:
54: WebService::Mattermost::V4::API::Object::Thread - A message thread.
55:
56: =head1 VERSION
57:
58: version 0.28
59:
60: =head1 DESCRIPTION
61:
62: Describes a list of Mattermost posts.
63:
64: =head2 ATTRIBUTES
65:
66: =over 4
67:
68: =item C<matches>
69:
70: If the posts are a search result, a list of strings that match.
71:
72: =item C<order>
73:
74: =item C<posts>
75:
76: An arrayref of posts in the list, ordered by date created.
77:
78: =back
79:
80: =head1 AUTHOR
81:
82: Mike Jones <mike@netsplit.org.uk>
83:
84: =head1 COPYRIGHT AND LICENSE
85:
86: This software is Copyright (c) 2020 by Mike Jones.
87:
88: This is free software, licensed under:
89:
90: The MIT (X11) License
91:
92: =cut
93: