X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FDebbugs%2FDB%2FResultSet%2FSuite.pm;fp=lib%2FDebbugs%2FDB%2FResultSet%2FSuite.pm;h=c920080f251c7a171608a13dafac363c397f3dd3;hb=1e6633a3780f4fd53fc4303852e84d13cdad2dc6;hp=0000000000000000000000000000000000000000;hpb=466f7faff129a5699c7674f59900a92aa256175d;p=debbugs.git diff --git a/lib/Debbugs/DB/ResultSet/Suite.pm b/lib/Debbugs/DB/ResultSet/Suite.pm new file mode 100644 index 0000000..c920080 --- /dev/null +++ b/lib/Debbugs/DB/ResultSet/Suite.pm @@ -0,0 +1,53 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later version. See the +# file README and COPYING for more information. +# Copyright 2017 by Don Armstrong . +use utf8; +package Debbugs::DB::ResultSet::Suite; + +=head1 NAME + +Debbugs::DB::ResultSet::Suite - Suite table actions + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + + + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::ResultSet'; + +sub get_suite_id { + my ($self,$suite) = @_; + if (ref($suite)) { + if (ref($suite) eq 'HASH') { + $suite = $suite->{id} + } else { + $suite = $suite->id(); + } + } + else { + if ($suite !~ /^\d+$/) { + $suite = $self->result_source->schema-> + resultset('Suite')-> + search_rs({codename => $suite}, + {result_class => 'DBIx::Class::ResultClass::HashRefInflator', + })->first(); + if (defined $suite) { + $suite = $suite->{id}; + } + } + } + return $suite; +} + +1; + +__END__