File Coverage

blib/lib/Slack/BlockKit/Block/RichText/Link.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::Link 0.005;
2             # ABSTRACT: a Block Kit rich text hyperlink element
3              
4 4     4   28 use Moose;
  4         8  
  4         32  
5 4     4   19489 use MooseX::StrictConstructor;
  4         10  
  4         40  
6              
7             with 'Slack::BlockKit::Role::HasBasicStyle';
8              
9             #pod =head1 OVERVIEW
10             #pod
11             #pod This represents a hyperlink element in rich text in Block Kit.
12             #pod
13             #pod =cut
14              
15 4     4   13843 use v5.36.0;
  4         15  
16              
17             #pod =attr url
18             #pod
19             #pod This is the URL to which the link links.
20             #pod
21             #pod =cut
22              
23             has url => (
24             is => 'ro',
25             isa => 'Str',
26             required => 1,
27             );
28              
29             #pod =attr text
30             #pod
31             #pod This is the text displayed for the link. It's optional, and Slack will display
32             #pod the URL if no text was given.
33             #pod
34             #pod This attribute stores a string, not any form of Block Kit text object.
35             #pod
36             #pod =cut
37              
38             has text => (
39             is => 'ro',
40             isa => 'Str',
41             predicate => 'has_text',
42             );
43              
44             #pod =attr unsafe
45             #pod
46             #pod This is a boolean indicating whether the link is unsafe. The author has not
47             #pod figured out what this actually I<does> and so never uses it.
48             #pod
49             #pod =cut
50              
51             has unsafe => (
52             is => 'ro',
53             isa => 'Bool',
54             predicate => 'has_unsafe',
55             );
56              
57             sub as_struct ($self) {
58             return {
59             type => 'link',
60              
61             ($self->has_text ? (text => q{} . $self->text) : ()),
62             ($self->has_unsafe ? (unsafe => Slack::BlockKit::boolify($self->unsafe)) : ()),
63             url => $self->url,
64             };
65             }
66              
67 4     4   29 no Moose;
  4         6  
  4         23  
68             __PACKAGE__->meta->make_immutable;
69              
70             __END__
71              
72             =pod
73              
74             =encoding UTF-8
75              
76             =head1 NAME
77              
78             Slack::BlockKit::Block::RichText::Link - a Block Kit rich text hyperlink element
79              
80             =head1 VERSION
81              
82             version 0.005
83              
84             =head1 OVERVIEW
85              
86             This represents a hyperlink element in rich text in Block Kit.
87              
88             =head1 PERL VERSION
89              
90             This module should work on any version of perl still receiving updates from
91             the Perl 5 Porters. This means it should work on any version of perl
92             released in the last two to three years. (That is, if the most recently
93             released version is v5.40, then this module should work on both v5.40 and
94             v5.38.)
95              
96             Although it may work on older versions of perl, no guarantee is made that the
97             minimum required version will not be increased. The version may be increased
98             for any reason, and there is no promise that patches will be accepted to
99             lower the minimum required perl.
100              
101             =head1 ATTRIBUTES
102              
103             =head2 url
104              
105             This is the URL to which the link links.
106              
107             =head2 text
108              
109             This is the text displayed for the link. It's optional, and Slack will display
110             the URL if no text was given.
111              
112             This attribute stores a string, not any form of Block Kit text object.
113              
114             =head2 unsafe
115              
116             This is a boolean indicating whether the link is unsafe. The author has not
117             figured out what this actually I<does> and so never uses it.
118              
119             =head1 AUTHOR
120              
121             Ricardo SIGNES <cpan@semiotic.systems>
122              
123             =head1 COPYRIGHT AND LICENSE
124              
125             This software is copyright (c) 2024 by Ricardo SIGNES.
126              
127             This is free software; you can redistribute it and/or modify it under
128             the same terms as the Perl 5 programming language system itself.
129              
130             =cut