1 package # hide from PAUSE
6 extends 'DBIx::Class::Schema', 'Moose::Object';
11 DBICNGTest::Schema; Schema Base For Testing Moose Roles, Traits, etc.
15 my $schema = DBICNGTest::Schema->connect($dsn);
17 ## Do anything you would as with a normal $schema object.
21 Defines the base case for loading DBIC Schemas. We add in some additional
22 helpful functions for administering you schemas. This namespace is dedicated
23 to integration of Moose based development practices.
25 =head1 PACKAGE METHODS
27 The following is a list of package methods declared with this class.
29 =head2 load_namespaces
31 Automatically load the classes and resultsets from their default namespaces.
35 __PACKAGE__->load_namespaces(
36 default_resultset_class => 'ResultSet',
42 This class defines the following attributes.
46 This module declares the following methods
50 overload new to make sure we get a good meta object and that the attributes all
51 get properly setup. This is done so that our instances properly get a L<Moose>
59 my $obj = $class->SUPER::new(@_);
61 return $class->meta->new_object(
62 __INSTANCE__ => $obj, @_
67 =head2 connect_and_setup
69 Creates a schema, deploys a database and sets the testing data.
73 sub connect_and_setup {
75 my $db_file = shift @_;
77 my ($dsn, $user, $pass) = (
78 $ENV{DBICNG_DSN} || "dbi:SQLite:${db_file}",
79 $ENV{DBICNG_USER} || '',
80 $ENV{DBICNG_PASS} || '',
84 ->connect($dsn, $user, $pass, { AutoCommit => 1 })
91 deploy a database and populate it with the initial data
98 $self->initial_populate(@_);
104 =head2 initial_populate
106 initializing the startup database information
110 sub initial_populate {
113 my @genders = $self->populate('Gender' => [
114 [qw(gender_id label)],
120 my @persons = $self->populate('Person' => [
121 [ qw(person_id fk_gender_id name age) ],
126 [ qw(5 3 steve 40) ],
129 my @friends = $self->populate('FriendList' => [
130 [ qw(fk_person_id fk_friend_id) ],
139 =head2 job_handler_echo
141 This is a method to test the job handler role.
145 sub job_handler_echo {
146 my ($schema, $job, $alert) = @_;
153 See L<DBIx::Class> for more information regarding authors.
157 You may distribute this code under the same terms as Perl itself.