File Coverage

blib/lib/RapidApp/Responder/InfoStatus.pm
Criterion Covered Total %
statement 12 16 75.0
branch n/a
condition n/a
subroutine 4 5 80.0
pod 0 1 0.0
total 16 22 72.7


line stmt bran cond sub pod time code
1             package RapidApp::Responder::InfoStatus;
2              
3 6     6   40 use Moose;
  6         11  
  6         46  
4             extends 'RapidApp::Responder';
5              
6 6     6   34854 use RapidApp::Util qw(:all);
  6         13  
  6         2133  
7 6     6   41 use HTML::Entities;
  6         11  
  6         829  
8              
9              
10             # Dead simple responder that can be thrown as an excption to abort something
11             # without displaying a message box. The response status can be set, and an optional
12             # info message header can be set. This is useful in cases where I user cancels
13             # from within customprompt logic and an exception has to be thrown to escape
14             # backend business logic safely (such as during a database transaction) but
15             # there is no actionable exception/message for the user.
16              
17             has 'status', is => 'ro', isa => 'Int', default => 200;
18             has 'msg', is => 'ro', isa => 'Str', default => '';
19              
20              
21             sub writeResponse {
22 0     0 0   my ($self, $c)= @_;
23            
24             # X-RapidApp-Info header not used yet, but it is intended to display a non-invasive status/info message
25 0           $c->response->header('X-RapidApp-Info' => $self->msg);
26            
27 0           $c->response->status($self->status);
28 0           $c->response->body('');
29             }
30              
31 6     6   42 no Moose;
  6         11  
  6         36  
32             __PACKAGE__->meta->make_immutable;
33             1;