File Coverage

blib/lib/WebService/Mattermost/V4/API/Object/Role/BelongingToChannel.pm
Criterion Covered Total %
statement 9 14 64.2
branch 0 2 0.0
condition n/a
subroutine 3 5 60.0
pod n/a
total 12 21 57.1


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

3: # ABSTRACT: Mark an object as belonging to a channel. 4:
5: use Moo::Role;
6: use Types::Standard qw(InstanceOf Maybe Str);
7:
8: use WebService::Mattermost::Helper::Alias 'view';
9:
10: ################################################################################
11:
12: has channel_id => (is => 'ro', isa => Maybe[Str], lazy => 1, builder => 1);
13: has channel => (is => 'ro', isa => Maybe[InstanceOf[view 'Channel']], lazy => 1, builder => 1);
14:
15: ################################################################################
16:
17: sub _build_channel_id {
18: my $self = shift;
19:
20: return $self->raw_data->{channel_id};
21: }
22:
23: sub _build_channel {
24: my $self = shift;
25:
26: return unless $self->channel_id;
27: return $self->api->channel->get($self->channel_id)->item;
28: }
29:
30: ################################################################################
31:
32: 1;
33:
34: __END__
35:
36: =pod
37:
38: =encoding UTF-8
39:
40: =head1 NAME
41:
42: WebService::Mattermost::V4::API::Object::Role::BelongingToChannel - Mark an object as belonging to a channel.
43:
44: =head1 VERSION
45:
46: version 0.30
47:
48: =head1 DESCRIPTION
49:
50: Link a view object to its channel.
51:
52: =head2 ATTRIBUTES
53:
54: =over 4
55:
56: =item C<channel_id>
57:
58: The channel's ID.
59:
60: =item C<channel>
61:
62: Linked L<WebService::Mattermost::V4::API::Object::Channel> object.
63:
64: =back
65:
66: =head1 AUTHOR
67:
68: Mike Jones <mike@netsplit.org.uk>
69:
70: =head1 COPYRIGHT AND LICENSE
71:
72: This software is Copyright (c) 2023 by Mike Jones.
73:
74: This is free software, licensed under:
75:
76: The MIT (X11) License
77:
78: =cut
79: