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   2117 use strict;
  4         11  
  4         108  
4 4     4   20 use warnings;
  4         7  
  4         88  
5              
6 4     4   20 use Moose::Role;
  4         8  
  4         24  
7              
8              
9 4     4   17039 use Try::Tiny;
  4         10  
  4         852  
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 50 my $self = shift;
22            
23 21 50       153 return unless ($self->can('load_saved_search'));
24            
25             try {
26 21     21   988 $self->Module('store'); # <-- Make sure store has already called ONREQUEST
27 21         88 $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         209 };
39             }
40              
41              
42 4     4   30 no Moose;
  4         8  
  4         35  
43             #__PACKAGE__->meta->make_immutable;
44             1;