File Coverage

blib/lib/CatalystX/OAuth2/Schema/Result/Token.pm
Criterion Covered Total %
statement 8 9 88.8
branch n/a
condition n/a
subroutine 6 7 85.7
pod 0 6 0.0
total 14 22 63.6


line stmt bran cond sub pod time code
1             package CatalystX::OAuth2::Schema::Result::Token;
2 8     8   16590 use parent 'DBIx::Class';
  8         27  
  8         76  
3              
4             # ABSTRACT: A table for registering bearer tokens
5              
6             __PACKAGE__->load_components(qw(Core));
7             __PACKAGE__->table('token');
8             __PACKAGE__->add_columns(
9             id => { data_type => 'int', is_auto_increment => 1 },
10             code_id => { data_type => 'int', is_nullable => 0 },
11             );
12             __PACKAGE__->set_primary_key(qw(id));
13             __PACKAGE__->belongs_to( code => 'CatalystX::OAuth2::Schema::Result::Code' =>
14             { 'foreign.id' => 'self.code_id' } );
15              
16             # this is a has many but will only ever return a single record
17             # because of the constraint on the relationship table
18             __PACKAGE__->has_many(
19             from_refresh_token_map =>
20             'CatalystX::OAuth2::Schema::Result::RefreshTokenToAccessToken' => {
21             'foreign.access_token_id' => 'self.id',
22             'foreign.code_id' => 'self.code_id'
23             }
24             );
25             __PACKAGE__->many_to_many(
26             from_refresh_token_map_m2m => from_refresh_token_map => 'refresh_token' );
27              
28             # this is a has many but will only ever return a single record
29             # because of the constraint on the relationship table
30             __PACKAGE__->has_many(
31             to_refresh_token_map =>
32             'CatalystX::OAuth2::Schema::Result::AccessTokenToRefreshToken' => {
33             'foreign.access_token_id' => 'self.id',
34             'foreign.code_id' => 'self.code_id'
35             }
36             );
37             __PACKAGE__->many_to_many(
38             to_refresh_token_map_m2m => to_refresh_token_map => 'refresh_token' );
39              
40 0     0 0 0 sub from_refresh_token { shift->from_refresh_token_map_m2m->first }
41 1     1 0 9 sub to_refresh_token { shift->to_refresh_token_map_m2m->first }
42              
43 8     8 0 13777 sub as_string { shift->id }
44 4     4 0 176 sub type {'bearer'}
45 4     4 0 25 sub expires_in {3600}
46 2     2 0 917 sub owner { shift->code->owner }
47              
48             1;
49              
50             __END__
51              
52             =pod
53              
54             =head1 NAME
55              
56             CatalystX::OAuth2::Schema::Result::Token - A table for registering bearer tokens
57              
58             =head1 VERSION
59              
60             version 0.001006
61              
62             =head1 AUTHOR
63              
64             Eden Cardim <edencardim@gmail.com>
65              
66             =head1 COPYRIGHT AND LICENSE
67              
68             This software is copyright (c) 2017 by Suretec Systems Ltd.
69              
70             This is free software; you can redistribute it and/or modify it under
71             the same terms as the Perl 5 programming language system itself.
72              
73             =cut