Client/Trait/HashStore.pm

filter: Statementstmt 96.3% 26 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod n/a totaltotal 94.8% 37 / 39 CC 1 SCAR 0.1
CC
1
Cov
96%
__ANON__
1.0
delete_stash
1.0
__ANON__
1.0
CRAP 1.0
« Client/ApiUserAgentBuilder.pm ↑ Summary Client/Error.pm »
1 package OIDC::Client::Trait::HashStore;
2 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use OIDC::Client::Utils qw(reach_data affect_data delete_data);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =encoding utf8
8  
9 =head1 NAME
10  
11 OIDC::Client::Trait::HashStore - Moose Trait for hashref stores
12  
13 =head1 DESCRIPTION
14  
15 This Moose Trait automatically adds methods to the instances of the class
16 based on the name of the attribute using it.
17  
18 Used by the C<OIDC::Client::Plugin::session> attribute, it adds read_session(), write_session()
19 and delete_session() methods to the instances of the L<OIDC::Client::Plugin> class.
20  
21 Used by the C<OIDC::Client::Plugin::stash> attribute, it adds read_stash(), write_stash()
22 and delete_stash() methods to the instances of the L<OIDC::Client::Plugin> class.
23  
24 C<read_${name}> method calls the L<OIDC::Client::Utils/"reach_data( $data_tree, \@path, $optional )">
25 function.
26  
27 C<write_${name}> method calls the L<OIDC::Client::Utils/"affect_data( $data_tree, \@path, $value )">
28 function.
29  
30 C<delete_${name}> method calls the L<OIDC::Client::Utils/"delete_data( $data_tree, \@path )">
31 function.
32  
33 =cut
34  
35 after 'install_accessors' => sub {
36 8 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
37 8 my $realclass = $self->associated_class();
38 8 my $name = $self->name;
39 8 ▶ $realclass->add_method("read_${name}" => sub { return scalar reach_data( $_[0]->$name, $_[1]) });
Subroutine read_stash: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
40 8 ▶ $realclass->add_method("write_${name}" => sub { return scalar affect_data($_[0]->$name, $_[1], $_[2]) });
Subroutine write_stash: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine write_session: called CC=1 SCAR=0.0
41 8 ▶ $realclass->add_method("delete_${name}" => sub { return scalar delete_data ($_[0]->$name, $_[1]) });
Subroutine delete_stash: called CC=1 SCAR=0.4
Subroutine __ANON__: not called CC=1 SCAR=0.4
42 4 };
43  
44 4 1;
« Client/ApiUserAgentBuilder.pm ↑ Summary Client/Error.pm »