]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/DB/ResultSet/Suite.pm
switch to compatibility level 12
[debbugs.git] / Debbugs / DB / ResultSet / Suite.pm
1 # This module is part of debbugs, and is released
2 # under the terms of the GPL version 2, or any later version. See the
3 # file README and COPYING for more information.
4 # Copyright 2017 by Don Armstrong <don@donarmstrong.com>.
5 use utf8;
6 package Debbugs::DB::ResultSet::Suite;
7
8 =head1 NAME
9
10 Debbugs::DB::ResultSet::Suite - Suite table actions
11
12 =head1 SYNOPSIS
13
14
15
16 =head1 DESCRIPTION
17
18
19
20 =cut
21
22 use strict;
23 use warnings;
24
25 use base 'DBIx::Class::ResultSet';
26
27 sub get_suite_id {
28     my ($self,$suite) = @_;
29     if (ref($suite)) {
30         if (ref($suite) eq 'HASH') {
31             $suite = $suite->{id}
32         } else {
33             $suite = $suite->id();
34         }
35     }
36     else {
37         if ($suite !~ /^\d+$/) {
38             $suite = $self->result_source->schema->
39                 resultset('Suite')->
40                 search_rs({codename => $suite},
41                          {result_class => 'DBIx::Class::ResultClass::HashRefInflator',
42                          })->first();
43             if (defined $suite) {
44                 $suite = $suite->{id};
45             }
46         }
47     }
48     return $suite;
49 }
50
51 1;
52
53 __END__