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   1389 use parent qw( JIRA::REST::Class::Abstract );
  4         6  
  4         18  
3 4     4   200 use strict;
  4         6  
  4         87  
4 4     4   22 use warnings;
  4         5  
  4         77  
5 4     4   47 use 5.010;
  4         13  
6              
7             our $VERSION = '0.12';
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   18 use Readonly 2.04;
  4         47  
  4         825  
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 Heumann Manni Melezhik iconUrl
109             updateAuthor
110              
111             =head1 NAME
112              
113             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.
114              
115             =head1 VERSION
116              
117             version 0.12
118              
119             =head1 METHODS
120              
121             =head2 B<delete>
122              
123             Deletes the comment from the issue. Returns nothing.
124              
125             =head1 READ-ONLY ACCESSORS
126              
127             =head2 B<author>
128              
129             The author of the comment as a
130             L<JIRA::REST::Class::User|JIRA::REST::Class::User> object.
131              
132             =head2 B<updateAuthor>
133              
134             The updateAuthor of the comment as a
135             L<JIRA::REST::Class::User|JIRA::REST::Class::User> object.
136              
137             =head2 B<created>
138              
139             The created date for the comment as a L<DateTime|DateTime> object.
140              
141             =head2 B<updated>
142              
143             The updated date for the comment as a L<DateTime|DateTime> object.
144              
145             =head2 B<body>
146              
147             The body of the comment as a string.
148              
149             =head2 B<id>
150              
151             The ID of the comment.
152              
153             =head2 B<self>
154              
155             The full URL for the JIRA REST API call for the comment.
156              
157             =head2 B<visibility>
158              
159             A hash reference representing the visibility of the comment.
160              
161             =head1 RELATED CLASSES
162              
163             =over 2
164              
165             =item * L<JIRA::REST::Class|JIRA::REST::Class>
166              
167             =item * L<JIRA::REST::Class::Abstract|JIRA::REST::Class::Abstract>
168              
169             =item * L<JIRA::REST::Class::User|JIRA::REST::Class::User>
170              
171             =back
172              
173             =head1 AUTHOR
174              
175             Packy Anderson <packy@cpan.org>
176              
177             =head1 COPYRIGHT AND LICENSE
178              
179             This software is Copyright (c) 2017 by Packy Anderson.
180              
181             This is free software, licensed under:
182              
183             The Artistic License 2.0 (GPL Compatible)
184              
185             =cut