File: Recipe.pm

package info (click to toggle)
libdata-objectdriver-perl 0.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 784 kB
  • sloc: perl: 3,795; sql: 64; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# $Id$

package Recipe;
use strict;
use base qw( Data::ObjectDriver::BaseObject );
use DodTestUtil;

use Data::ObjectDriver::Driver::DBI;

__PACKAGE__->install_properties({
    columns => [ 'recipe_id', 'partition_id', 'title' ],
    datasource => 'recipes',
    primary_key => 'recipe_id',
    driver => Data::ObjectDriver::Driver::DBI->new(
        dsn      => DodTestUtil::dsn('global'),
        reuse_dbh => 1,
    ),
});

my %drivers;
__PACKAGE__->has_partitions(
    number => 2,
    get_driver => sub {
        my $cluster = shift;
        my $driver = $drivers{$cluster} ||= 
            Data::ObjectDriver::Driver::DBI->new(
                dsn => DodTestUtil::dsn('cluster' . $cluster),
                reuse_dbh => 1,
                @_,
            );
        return $driver;
    },
);

1;