NAME

DBIx::Class::Factory - factory-style fixtures for DBIx::Class

VERSION

Version 0.01

SYNOPSIS

{ package My::UserFactory;

use base qw(DBIx::Class::Factory);

__PACKAGE__->resultset(My::Schema->resultset('User'));
__PACKAGE__->fields({
    name => __PACKAGE__->seq(sub {'User #' . shift}),
    superuser => 0,
});
}

# Creates users with 'User #0' .. 'User #3\6' names My::UserFactory->create_batch(7, {status => 0});

DESCRIPTION

Creating the big fixtures batch may be a pain. This module provides easy way of creating data in database via DBIx::Class.

To create a factory just derive from DBIx::Class::Factory and add some defaults. You also can add some data at the moment of creating instance, redefining factory defaults.

Tests for this module contains a bunch of usefull examples.

METHODS TO CONSTRUCT FACTORY

base_factory

Use this to create one factory derived from another. Don't user direct inheritance.

{
    package My::UserFactory;

    use base qw(DBIx::Class::Factory);

    __PACKAGE__->resultset(My::Schema->resultset('User'));
    __PACKAGE__->fields({
        name => __PACKAGE__->seq(sub {'User #' . shift}),
        superuser => 0,
    });
}

{
    package My::SuperUserFactory;

    use base qw(DBIx::Class::Factory);

    __PACKAGE__->base_factory('My::UserFactory');
    __PACKAGE__->fields({
        superuser => 1,
    });
}

HELPERS

METHODS TO USE OUTSIDE

METHOD TO OVERRIDE

PRIVATE METHODS

AUTHOR

Vadim Pushtaev, <pushtaev at cpan.org>

BUGS

Please report any bugs or feature requests to bug-dbix-class-factory at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-Factory. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc DBIx::Class::Factory

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2015 Vadim Pushtaev.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 140:

You forgot a '=back' before '=head1'