File Coverage

blib/lib/Slack/BlockKit/Block/Header.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Slack::BlockKit::Block::Header 0.005;
2             # ABSTRACT: a Block Kit header block
3              
4 4     4   31 use Moose;
  4         12  
  4         34  
5 4     4   33073 use MooseX::StrictConstructor;
  4         11  
  4         39  
6              
7             with 'Slack::BlockKit::Role::Block';
8              
9             #pod =head1 OVERVIEW
10             #pod
11             #pod This object represents a "header" block. These blocks only have one special
12             #pod attribute: the text they display.
13             #pod
14             #pod =cut
15              
16 4     4   18428 use v5.36.0;
  4         18  
17              
18 4     4   24 use Moose::Util::TypeConstraints qw(class_type);
  4         9  
  4         59  
19              
20             #pod =attr text
21             #pod
22             #pod The C<text> attribute must be a L<text object|Slack::BlockKit::CompObj::Text>
23             #pod with the text that will be displayed in the header. The C<type> of that object
24             #pod must be C<plain_text>, not C<mrkdwn>.
25             #pod
26             #pod =cut
27              
28             has text => (
29             is => 'ro',
30             isa => class_type('Slack::BlockKit::CompObj::Text'),
31             required => 1,
32             );
33              
34 2     2 0 5 sub BUILD ($self, @) {
  2         3  
  2         4  
35 2 100       2521 if ($self->text->type ne 'plain_text') {
36 1         328 Carp::croak("non-plain_text text object provided to header");
37             }
38             }
39              
40             sub as_struct ($self) {
41             return {
42             type => 'header',
43             text => $self->text->as_struct,
44             };
45             }
46              
47 4     4   2842 no Moose;
  4         8  
  4         22  
48             __PACKAGE__->meta->make_immutable;
49              
50             __END__
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             Slack::BlockKit::Block::Header - a Block Kit header block
59              
60             =head1 VERSION
61              
62             version 0.005
63              
64             =head1 OVERVIEW
65              
66             This object represents a "header" block. These blocks only have one special
67             attribute: the text they display.
68              
69             =head1 PERL VERSION
70              
71             This module should work on any version of perl still receiving updates from
72             the Perl 5 Porters. This means it should work on any version of perl
73             released in the last two to three years. (That is, if the most recently
74             released version is v5.40, then this module should work on both v5.40 and
75             v5.38.)
76              
77             Although it may work on older versions of perl, no guarantee is made that the
78             minimum required version will not be increased. The version may be increased
79             for any reason, and there is no promise that patches will be accepted to
80             lower the minimum required perl.
81              
82             =head1 ATTRIBUTES
83              
84             =head2 text
85              
86             The C<text> attribute must be a L<text object|Slack::BlockKit::CompObj::Text>
87             with the text that will be displayed in the header. The C<type> of that object
88             must be C<plain_text>, not C<mrkdwn>.
89              
90             =head1 AUTHOR
91              
92             Ricardo SIGNES <cpan@semiotic.systems>
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is copyright (c) 2024 by Ricardo SIGNES.
97              
98             This is free software; you can redistribute it and/or modify it under
99             the same terms as the Perl 5 programming language system itself.
100              
101             =cut