File Coverage

blib/lib/RapidApp/Module/StorCmp/Role/SavedSearch.pm
Criterion Covered Total %
statement 20 22 90.9
branch 1 2 50.0
condition n/a
subroutine 7 9 77.7
pod 0 2 0.0
total 28 35 80.0


line stmt bran cond sub pod time code
1             package RapidApp::Module::StorCmp::Role::SavedSearch;
2              
3 4     4   2536 use strict;
  4         10  
  4         108  
4 4     4   19 use warnings;
  4         8  
  4         95  
5              
6 4     4   31 use Moose::Role;
  4         7  
  4         25  
7              
8              
9 4     4   17407 use Try::Tiny;
  4         10  
  4         882  
10              
11             #### --------------------- ####
12              
13       0 0   sub BUILD {}
14             before 'BUILD' => sub {
15             my $self = shift;
16             $self->add_ONREQUEST_calls_early('run_load_saved_search');
17             };
18              
19              
20             sub run_load_saved_search {
21 21     21 0 51 my $self = shift;
22            
23 21 50       144 return unless ($self->can('load_saved_search'));
24            
25             try {
26 21     21   984 $self->Module('store'); # <-- Make sure store has already called ONREQUEST
27 21         92 $self->load_saved_search;
28             }
29             catch {
30 0     0     my $err = $_;
31 0           $self->set_response_warning({
32             title => 'Error loading search',
33             msg =>
34             'An error occured while trying to load the saved search. The default view has been loaded.' . "\n\n" .
35             'DETAIL:' . "\n\n" .
36             '<pre>' . $err . '</pre>'
37             });
38 21         243 };
39             }
40              
41              
42 4     4   29 no Moose;
  4         9  
  4         28  
43             #__PACKAGE__->meta->make_immutable;
44             1;