File Coverage

blib/lib/Slack/BlockKit/Block/Context.pm
Criterion Covered Total %
statement 26 26 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod n/a
total 35 35 100.0


line stmt bran cond sub pod time code
1             package Slack::BlockKit::Block::Context 0.005;
2             # ABSTRACT: a Block Kit context block, used to collect images and text
3              
4 4     4   32 use Moose;
  4         8  
  4         42  
5 4     4   34153 use MooseX::StrictConstructor;
  4         11  
  4         45  
6              
7             with 'Slack::BlockKit::Role::Block';
8              
9             #pod =head1 OVERVIEW
10             #pod
11             #pod This represents a C<context> block, which is commonly used to contain text to
12             #pod be sent. Don't confuse this class with L<Slack::BlockKit::Block::RichText> or
13             #pod L<Slack::BlockKit::Block::RichText::Section>, which are used to present I<rich>
14             #pod text. A "normal" section block can only present rich text in the form of
15             #pod C<mrkdwn>-type text objects.
16             #pod
17             #pod A C<context> block is similar to a C<section> block, but can contain images.
18             #pod Also, it seems like a C<section> block is a bit smaller, textwise? It's a bit
19             #pod of a muddle.
20             #pod
21             #pod =cut
22              
23 4     4   16231 use v5.36.0;
  4         16  
24              
25 4     4   27 use Moose::Util::TypeConstraints qw(class_type);
  4         8  
  4         48  
26 4     4   2326 use MooseX::Types::Moose qw(ArrayRef);
  4         11  
  4         79  
27              
28 4     4   26225 use Slack::BlockKit::Types qw(ContextElementList);
  4         10  
  4         40  
29              
30             #pod =attr elements
31             #pod
32             #pod This must be an arrayref of element objects, of either text or image types.
33             #pod (At present, though, Slack::BlockKit does not support image elements.)
34             #pod
35             #pod =cut
36              
37             has elements => (
38             isa => ContextElementList(),
39             traits => [ 'Array' ],
40             handles => { elements => 'elements' },
41             );
42              
43             sub as_struct ($self) {
44             return {
45             type => 'context',
46             elements => [ map {; $_->as_struct } $self->elements ],
47             }
48             }
49              
50 4     4   10049 no Moose;
  4         13  
  4         33  
51 4     4   1199 no Moose::Util::TypeConstraints;
  4         10  
  4         25  
52 4     4   729 no MooseX::Types::Moose;
  4         10  
  4         241  
53             __PACKAGE__->meta->make_immutable;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Slack::BlockKit::Block::Context - a Block Kit context block, used to collect images and text
64              
65             =head1 VERSION
66              
67             version 0.005
68              
69             =head1 OVERVIEW
70              
71             This represents a C<context> block, which is commonly used to contain text to
72             be sent. Don't confuse this class with L<Slack::BlockKit::Block::RichText> or
73             L<Slack::BlockKit::Block::RichText::Section>, which are used to present I<rich>
74             text. A "normal" section block can only present rich text in the form of
75             C<mrkdwn>-type text objects.
76              
77             A C<context> block is similar to a C<section> block, but can contain images.
78             Also, it seems like a C<section> block is a bit smaller, textwise? It's a bit
79             of a muddle.
80              
81             =head1 PERL VERSION
82              
83             This module should work on any version of perl still receiving updates from
84             the Perl 5 Porters. This means it should work on any version of perl
85             released in the last two to three years. (That is, if the most recently
86             released version is v5.40, then this module should work on both v5.40 and
87             v5.38.)
88              
89             Although it may work on older versions of perl, no guarantee is made that the
90             minimum required version will not be increased. The version may be increased
91             for any reason, and there is no promise that patches will be accepted to
92             lower the minimum required perl.
93              
94             =head1 ATTRIBUTES
95              
96             =head2 elements
97              
98             This must be an arrayref of element objects, of either text or image types.
99             (At present, though, Slack::BlockKit does not support image elements.)
100              
101             =head1 AUTHOR
102              
103             Ricardo SIGNES <cpan@semiotic.systems>
104              
105             =head1 COPYRIGHT AND LICENSE
106              
107             This software is copyright (c) 2024 by Ricardo SIGNES.
108              
109             This is free software; you can redistribute it and/or modify it under
110             the same terms as the Perl 5 programming language system itself.
111              
112             =cut