File Coverage

blib/lib/CatalystX/OAuth2/Schema/Result/Code.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 2 0.0
total 9 11 81.8


line stmt bran cond sub pod time code
1             package CatalystX::OAuth2::Schema::Result::Code;
2 8     8   14062 use parent 'DBIx::Class';
  8         28  
  8         78  
3              
4             # ABSTRACT: A table for registering grant codes
5              
6             __PACKAGE__->load_components(qw(Core));
7             __PACKAGE__->table('code');
8             __PACKAGE__->add_columns(
9             client_id => { data_type => 'int', is_nullable => 0 },
10             id => { data_type => 'int', is_auto_increment => 1, is_nullable => 0 },
11             is_active => { data_type => 'int', is_nullable => 0, default_value => 0 },
12             owner_id => { data_type => 'int', is_nullable => 1 }
13             );
14             __PACKAGE__->set_primary_key(qw(id));
15             __PACKAGE__->belongs_to(
16             client => 'CatalystX::OAuth2::Schema::Result::Client' =>
17             { 'foreign.id' => 'self.client_id' } );
18             __PACKAGE__->has_many( tokens => 'CatalystX::OAuth2::Schema::Result::Token' =>
19             { 'foreign.code_id' => 'self.id' } );
20             __PACKAGE__->has_many(
21             refresh_tokens => 'CatalystX::OAuth2::Schema::Result::RefreshToken' =>
22             { 'foreign.code_id' => 'self.id' } );
23             __PACKAGE__->belongs_to(
24             owner => 'CatalystX::OAuth2::Schema::Result::Owner',
25             { 'foreign.id' => 'self.owner_id' }
26             );
27              
28 13     13 0 79509 sub as_string { shift->id }
29              
30             sub activate {
31 2     2 0 8 my($self, $owner_id) = @_;
32 2         51 $self->update( { is_active => 1, owner_id => $owner_id } )
33             }
34              
35             1;
36              
37             __END__
38              
39             =pod
40              
41             =head1 NAME
42              
43             CatalystX::OAuth2::Schema::Result::Code - A table for registering grant codes
44              
45             =head1 VERSION
46              
47             version 0.001006
48              
49             =head1 AUTHOR
50              
51             Eden Cardim <edencardim@gmail.com>
52              
53             =head1 COPYRIGHT AND LICENSE
54              
55             This software is copyright (c) 2017 by Suretec Systems Ltd.
56              
57             This is free software; you can redistribute it and/or modify it under
58             the same terms as the Perl 5 programming language system itself.
59              
60             =cut