File Coverage

blib/lib/CatalystX/OAuth2/Controller/Role/WithStore.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package CatalystX::OAuth2::Controller::Role::WithStore;
2 8     8   5967 use Moose::Role;
  8         24  
  8         74  
3              
4             # ABSTRACT: A role for providing oauth2 stores to controllers
5              
6             has store => (
7             does => 'CatalystX::OAuth2::Store',
8             is => 'ro',
9             required => 1
10             );
11              
12             around BUILDARGS => sub {
13             my $orig = shift;
14             my $self = shift;
15             my $args = $self->$orig(@_);
16             return $args unless @_ == 2;
17             my ($app) = @_;
18             for ( $args->{store} ) {
19             last unless defined and ref eq 'HASH';
20             my $store_args = {%$_};
21             my $class = delete $store_args->{class};
22             $class = "CatalystX::OAuth2::Store::$class" unless $class =~ /^\+/;
23             my ( $is_success, $error ) = Class::Load::try_load_class($class);
24             die qq{Couldn't load OAuth2 store '$class': $error} unless $is_success;
25             $args->{store} = $class->new( %$store_args, app => $app );
26             }
27             return $args;
28             };
29              
30             1;
31              
32             __END__
33              
34             =pod
35              
36             =head1 NAME
37              
38             CatalystX::OAuth2::Controller::Role::WithStore - A role for providing oauth2 stores to controllers
39              
40             =head1 VERSION
41              
42             version 0.001006
43              
44             =head1 AUTHOR
45              
46             Eden Cardim <edencardim@gmail.com>
47              
48             =head1 COPYRIGHT AND LICENSE
49              
50             This software is copyright (c) 2017 by Suretec Systems Ltd.
51              
52             This is free software; you can redistribute it and/or modify it under
53             the same terms as the Perl 5 programming language system itself.
54              
55             =cut