File Coverage

blib/lib/Slack/BlockKit/Block/RichText/User.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Slack::BlockKit::Block::RichText::User 0.005;
2             # ABSTRACT: a Block Kit rich text element that mentions a @user
3              
4 4     4   29 use Moose;
  4         8  
  4         35  
5 4     4   20223 use MooseX::StrictConstructor;
  4         6  
  4         61  
6              
7             with 'Slack::BlockKit::Role::HasMentionStyle';
8              
9             #pod =head1 OVERVIEW
10             #pod
11             #pod This represents the mention of a specific Slack user in a hunk of rich text.
12             #pod The user name will be styled and linked-to. So, to send something like:
13             #pod
14             #pod I was discussing this with @rjbs.
15             #pod
16             #pod You would use the L<sugar|Slack::BlockKit::Sugar> like so:
17             #pod
18             #pod blocks(richtext(section(
19             #pod "I was discussing this with ", user($user_id), "."
20             #pod )));
21             #pod
22             #pod =cut
23              
24 4     4   13908 use v5.36.0;
  4         15  
25              
26             #pod =attr user_id
27             #pod
28             #pod This must be the Slack user id for the user being mentioned. This is generally
29             #pod a bunch of alphanumeric characters beginning with C<U>.
30             #pod
31             #pod =cut
32              
33             has user_id => (
34             is => 'ro',
35             isa => 'Str',
36             required => 1,
37             );
38              
39             sub as_struct ($self) {
40             return {
41             type => 'user',
42             user_id => $self->user_id,
43             };
44             }
45              
46 4     4   24 no Moose;
  4         9  
  4         25  
47             __PACKAGE__->meta->make_immutable;
48              
49             __END__
50              
51             =pod
52              
53             =encoding UTF-8
54              
55             =head1 NAME
56              
57             Slack::BlockKit::Block::RichText::User - a Block Kit rich text element that mentions a @user
58              
59             =head1 VERSION
60              
61             version 0.005
62              
63             =head1 OVERVIEW
64              
65             This represents the mention of a specific Slack user in a hunk of rich text.
66             The user name will be styled and linked-to. So, to send something like:
67              
68             I was discussing this with @rjbs.
69              
70             You would use the L<sugar|Slack::BlockKit::Sugar> like so:
71              
72             blocks(richtext(section(
73             "I was discussing this with ", user($user_id), "."
74             )));
75              
76             =head1 PERL VERSION
77              
78             This module should work on any version of perl still receiving updates from
79             the Perl 5 Porters. This means it should work on any version of perl
80             released in the last two to three years. (That is, if the most recently
81             released version is v5.40, then this module should work on both v5.40 and
82             v5.38.)
83              
84             Although it may work on older versions of perl, no guarantee is made that the
85             minimum required version will not be increased. The version may be increased
86             for any reason, and there is no promise that patches will be accepted to
87             lower the minimum required perl.
88              
89             =head1 ATTRIBUTES
90              
91             =head2 user_id
92              
93             This must be the Slack user id for the user being mentioned. This is generally
94             a bunch of alphanumeric characters beginning with C<U>.
95              
96             =head1 AUTHOR
97              
98             Ricardo SIGNES <cpan@semiotic.systems>
99              
100             =head1 COPYRIGHT AND LICENSE
101              
102             This software is copyright (c) 2024 by Ricardo SIGNES.
103              
104             This is free software; you can redistribute it and/or modify it under
105             the same terms as the Perl 5 programming language system itself.
106              
107             =cut