File Coverage

blib/lib/Mojito/Auth.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1 1     1   25465 use strictures 1;
  1         801  
  1         34  
2             package Mojito::Auth;
3             {
4             $Mojito::Auth::VERSION = '0.24';
5             }
6 1     1   598 use Mojito::Auth::Mongo;
  0            
  0            
7             use Mojito::Auth::Deep;
8             use Mojito::Auth::Elasticsearch;
9             use Moo;
10              
11             =head1 Name
12              
13             Mojito::Auth - authentication delegator class
14              
15             =cut
16              
17             has 'auth' => (
18             is => 'ro',
19             lazy => 1,
20             writer => '_set_auth',
21             handles => [ qw( digest_authen_cb _secret get_user add_user remove_user username realm password clear_db_name db_name) ],
22             );
23              
24             sub BUILD {
25             my ($self, $constructor_args_href) = @_;
26            
27             # Determine the document store backend from the configuration
28             my $doc_storage = ucfirst lc $constructor_args_href->{config}->{document_storage};
29             my $delegatee = __PACKAGE__ . '::' . $doc_storage;
30             $self->_set_auth($delegatee->new($constructor_args_href));
31             }
32              
33             1