File Coverage

lib/JIRA/REST/Class/Issue/Comment.pm
Criterion Covered Total %
statement 14 25 56.0
branch n/a
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 21 34 61.7


line stmt bran cond sub pod time code
1             package JIRA::REST::Class::Issue::Comment;
2 4     4   1776 use parent qw( JIRA::REST::Class::Abstract );
  4         7  
  4         19  
3 4     4   251 use strict;
  4         9  
  4         64  
4 4     4   17 use warnings;
  4         8  
  4         80  
5 4     4   51 use 5.010;
  4         12  
6              
7             our $VERSION = '0.11';
8             our $SOURCE = 'CPAN';
9             ## $SOURCE = 'GitHub'; # COMMENT
10             # the line above will be commented out by Dist::Zilla
11              
12             # ABSTRACT: A helper class for L<JIRA::REST::Class|JIRA::REST::Class> that represents a comment on a JIRA issue as an object.
13              
14 4     4   22 use Readonly 2.04;
  4         53  
  4         782  
15              
16             # fields that will be turned into JIRA::REST::Class::User objects
17             Readonly my @USERS => qw( author updateAuthor );
18              
19             # fields that will be turned into DateTime objects
20             Readonly my @DATES => qw( created updated );
21              
22             __PACKAGE__->mk_ro_accessors( @USERS, @DATES );
23              
24             __PACKAGE__->mk_data_ro_accessors( qw/ body id self visibility / );
25              
26             __PACKAGE__->mk_contextual_ro_accessors();
27              
28             sub init {
29 0     0 1   my $self = shift;
30 0           $self->SUPER::init( @_ );
31              
32             # make user objects
33 0           foreach my $field ( @USERS ) {
34 0           $self->populate_scalar_data( $field, 'user', $field );
35             }
36              
37             # make date objects
38 0           foreach my $field ( @DATES ) {
39 0           $self->{$field} = $self->make_date( $self->data->{$field} );
40             }
41              
42 0           return;
43             }
44              
45             #pod =method B<delete>
46             #pod
47             #pod Deletes the comment from the issue. Returns nothing.
48             #pod
49             #pod =cut
50              
51             sub delete { ## no critic (ProhibitBuiltinHomonyms)
52 0     0 1   my $self = shift;
53 0           $self->issue->delete( '/comment/' . $self->id );
54              
55             # now that we've deleted this comment, the
56             # lazy accessor will need to be reloaded
57 0           undef $self->issue->{comments};
58              
59 0           return;
60             }
61              
62             1;
63              
64             #pod =accessor B<author>
65             #pod
66             #pod The author of the comment as a
67             #pod L<JIRA::REST::Class::User|JIRA::REST::Class::User> object.
68             #pod
69             #pod =accessor B<updateAuthor>
70             #pod
71             #pod The updateAuthor of the comment as a
72             #pod L<JIRA::REST::Class::User|JIRA::REST::Class::User> object.
73             #pod
74             #pod =accessor B<created>
75             #pod
76             #pod The created date for the comment as a L<DateTime|DateTime> object.
77             #pod
78             #pod =accessor B<updated>
79             #pod
80             #pod The updated date for the comment as a L<DateTime|DateTime> object.
81             #pod
82             #pod =accessor B<body>
83             #pod
84             #pod The body of the comment as a string.
85             #pod
86             #pod =accessor B<id>
87             #pod
88             #pod The ID of the comment.
89             #pod
90             #pod =accessor B<self>
91             #pod
92             #pod The full URL for the JIRA REST API call for the comment.
93             #pod
94             #pod =accessor B<visibility>
95             #pod
96             #pod A hash reference representing the visibility of the comment.
97             #pod
98             #pod =for stopwords iconUrl updateAuthor
99             #pod
100             #pod =cut
101              
102             __END__
103              
104             =pod
105              
106             =encoding UTF-8
107              
108             =for :stopwords Packy Anderson Alexandr Alexey Ciornii Melezhik iconUrl updateAuthor
109              
110             =head1 NAME
111              
112             JIRA::REST::Class::Issue::Comment - A helper class for L<JIRA::REST::Class|JIRA::REST::Class> that represents a comment on a JIRA issue as an object.
113              
114             =head1 VERSION
115              
116             version 0.11
117              
118             =head1 METHODS
119              
120             =head2 B<delete>
121              
122             Deletes the comment from the issue. Returns nothing.
123              
124             =head1 READ-ONLY ACCESSORS
125              
126             =head2 B<author>
127              
128             The author of the comment as a
129             L<JIRA::REST::Class::User|JIRA::REST::Class::User> object.
130              
131             =head2 B<updateAuthor>
132              
133             The updateAuthor of the comment as a
134             L<JIRA::REST::Class::User|JIRA::REST::Class::User> object.
135              
136             =head2 B<created>
137              
138             The created date for the comment as a L<DateTime|DateTime> object.
139              
140             =head2 B<updated>
141              
142             The updated date for the comment as a L<DateTime|DateTime> object.
143              
144             =head2 B<body>
145              
146             The body of the comment as a string.
147              
148             =head2 B<id>
149              
150             The ID of the comment.
151              
152             =head2 B<self>
153              
154             The full URL for the JIRA REST API call for the comment.
155              
156             =head2 B<visibility>
157              
158             A hash reference representing the visibility of the comment.
159              
160             =head1 RELATED CLASSES
161              
162             =over 2
163              
164             =item * L<JIRA::REST::Class|JIRA::REST::Class>
165              
166             =item * L<JIRA::REST::Class::Abstract|JIRA::REST::Class::Abstract>
167              
168             =item * L<JIRA::REST::Class::User|JIRA::REST::Class::User>
169              
170             =back
171              
172             =head1 AUTHOR
173              
174             Packy Anderson <packy@cpan.org>
175              
176             =head1 COPYRIGHT AND LICENSE
177              
178             This software is Copyright (c) 2017 by Packy Anderson.
179              
180             This is free software, licensed under:
181              
182             The Artistic License 2.0 (GPL Compatible)
183              
184             =cut