File Coverage

blib/lib/IMDB/Local/Genre.pm
Criterion Covered Total %
statement 27 53 50.9
branch 0 10 0.0
condition n/a
subroutine 9 14 64.2
pod 0 5 0.0
total 36 82 43.9


line stmt bran cond sub pod time code
1             package IMDB::Local::Genre;
2              
3 1     1   11 use 5.006;
  1         2  
  1         26  
4 1     1   3 use strict;
  1         1  
  1         19  
5 1     1   3 use warnings;
  1         1  
  1         30  
6              
7             =head1 NAME
8              
9             IMDB::Local::Genre - Object representation of Genre information.
10              
11             =head1 VERSION
12              
13             Version 0.01
14              
15             =cut
16              
17             our $VERSION = '1.00';
18              
19              
20             =head1 SYNOPSIS
21              
22             Quick summary of what the module does.
23              
24             Perhaps a little code snippet.
25              
26             use IMDB::Local::Genre;
27              
28             my $foo = IMDB::Local::Genre->new();
29             ...
30              
31             =head1 EXPORT
32              
33             A list of functions that can be exported. You can delete this section
34             if you don't export anything, such as for a purely object-oriented module.
35              
36             =head1 SUBROUTINES/METHODS
37              
38             =head2 function1
39              
40             =cut
41              
42 1     1   3 use IMDB::Local::DB::BaseObject;
  1         1  
  1         5  
43 1     1   23 use base qw(IMDB::Local::DB::BaseObject);
  1         1  
  1         56  
44              
45 1     1   4 use constant DB_TABLE => 'Genres';
  1         1  
  1         38  
46 1     1   3 use constant DB_KEY => 'GenreID';
  1         1  
  1         46  
47              
48             use Class::MethodMaker
49             [
50 1         6 scalar => [DB_KEY],
51             array => [qw/ -static db_columns/],
52             new => [qw/ -init -hash new/] ,
53 1     1   4 ];
  1         1  
54              
55             sub init($)
56             {
57 0     0 0   my ($self)=@_;
58              
59             # static array needs to be initialized only if it isn't already
60             #if ( !$self->db_ignoredColumns_count ) {
61             #$self->db_ignoredColumns_push(DB_COLUMNS_IGNORE);
62             #}
63              
64 0           $self->initHandle(DB_TABLE, DB_KEY);
65              
66 0 0         if ( $self->populateUsingKey($self->get(DB_KEY)) ) {
67 0           return $self;
68             }
69 0           return(undef);
70             }
71              
72 1     1   1010 use Carp;
  1         1  
  1         345  
73              
74             sub createNew($%)
75             {
76 0     0 0   my ($imdbdb, %args)=@_;
77              
78 0 0         carp("no name given") if ( !defined($args{name}) );
79              
80 0           my $id=$imdbdb->insert_db(DB_TABLE, DB_KEY, %args);
81 0 0         if ( !defined($id) ) {
82 0           return(undef);
83             }
84 0           return new IMDB::Local::Genre(imdbdb=>$imdbdb, TableID=>$id);
85             }
86              
87             sub findByGenreID($$)
88             {
89 0     0 0   my ($imdbdb, $id)=@_;
90 0           return new IMDB::Local::Genre(imdbdb=>$imdbdb, DB_KEY, $id);
91             }
92              
93             sub findByName($$)
94             {
95 0     0 0   my ($imdbdb, $name)=@_;
96              
97 0           my $id=$imdbdb->select2Scalar("SELECT ".DB_KEY." from ".DB_TABLE." where name='$name'");
98 0 0         if ( defined($id) ) {
99 0           return new IMDB::Local::Genre(imdbdb=>$imdbdb, DB_KEY, $id);
100             }
101 0           return(undef);
102             }
103              
104             sub getIDs($$)
105             {
106 0     0 0   my ($class, $imdbdb)=@_;
107 0           my @ids;
108              
109 0           my $res=$imdbdb->dbh->selectall_arrayref("SELECT ".DB_KEY." FROM ".DB_TABLE." ORDER BY ".DB_KEY."");
110 0 0         if ( !defined($res) ) {
111 0           return(@ids);
112             }
113              
114 0           for my $list (@$res) {
115 0           push(@ids, $list->[0]);
116             }
117 0           return(@ids);
118             }
119              
120             =head1 AUTHOR
121              
122             jerryv, C<< >>
123              
124             =head1 BUGS
125              
126             Please report any bugs or feature requests to C, or through
127             the web interface at L. I will be notified, and then you'll
128             automatically be notified of progress on your bug as I make changes.
129              
130              
131              
132              
133             =head1 SUPPORT
134              
135             You can find documentation for this module with the perldoc command.
136              
137             perldoc IMDB::Local::Genre
138              
139              
140             You can also look for information at:
141              
142             =over 4
143              
144             =item * RT: CPAN's request tracker (report bugs here)
145              
146             L
147              
148             =item * AnnoCPAN: Annotated CPAN documentation
149              
150             L
151              
152             =item * CPAN Ratings
153              
154             L
155              
156             =item * Search CPAN
157              
158             L
159              
160             =back
161              
162              
163             =head1 ACKNOWLEDGEMENTS
164              
165              
166             =head1 LICENSE AND COPYRIGHT
167              
168             Copyright 2015 jerryv.
169              
170             This program is free software; you can redistribute it and/or modify it
171             under the terms of the the Artistic License (2.0). You may obtain a
172             copy of the full license at:
173              
174             L
175              
176             Any use, modification, and distribution of the Standard or Modified
177             Versions is governed by this Artistic License. By using, modifying or
178             distributing the Package, you accept this license. Do not use, modify,
179             or distribute the Package, if you do not accept this license.
180              
181             If your Modified Version has been derived from a Modified Version made
182             by someone other than you, you are nevertheless required to ensure that
183             your Modified Version complies with the requirements of this license.
184              
185             This license does not grant you the right to use any trademark, service
186             mark, tradename, or logo of the Copyright Holder.
187              
188             This license includes the non-exclusive, worldwide, free-of-charge
189             patent license to make, have made, use, offer to sell, sell, import and
190             otherwise transfer the Package with respect to any patent claims
191             licensable by the Copyright Holder that are necessarily infringed by the
192             Package. If you institute patent litigation (including a cross-claim or
193             counterclaim) against any party alleging that the Package constitutes
194             direct or contributory patent infringement, then this Artistic License
195             to you shall terminate on the date that such litigation is filed.
196              
197             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
198             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
199             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
200             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
201             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
202             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
203             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
204             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
205              
206              
207             =cut
208              
209             1; # End of IMDB::Local::Genre