NAME

Catalyst::Model::EmailStore - Email::Store Model Class

SYNOPSIS

    # use the helper
    create model EmailStore EmailStore dsn user password

    # lib/MyApp/Model/EmailStore.pm
    package MyApp::Model::EmailStore;

    use base 'Catalyst::Model::EmailStore';

    __PACKAGE__->config(
        dsn                    => 'dbi:Pg:dbname=myapp',
        password               => '',
        user                   => 'postgres',
        options                => { AutoCommit => 1 },
        cdbi_plugins           => [ qw/AbstractCount Pager/ ],
        upgrade_relationships  => 1
    );

    1;

    # As object method
    $c->model('EmailStore::Address')->search(...);

    # As class method
    MyApp::Model::EmailStore::Adress->search(...);

DESCRIPTION

This is the Email::Store model class. It will automatically subclass all model classes from the Email::Store namespace and import them into your application. For this purpose a class is considered to be a model if it descends from Email::Store::DBI.

This class is also doing its best to upgrade the relationships of all Email::Store models (i.e. MyApp::Model::EmailStore::Entity::Name will have many MyApp::Model::EmailStore::Addressing objects instead of Email::Store::Addressing ones). But be warned that this will not affect event handlers in any way. If you want to extend or modify these you are still stuck in the Email::Store namespace unfortunatly.

CAVEATS

Due to limitations in the design of Email::Store the main model class (e.g. MyApp::Model::EmailStore) is not part of the inheritance chain that leads up to Class::DBI so you can't use any CDBI plugins there. To alleviate this problem a config option named cdbi_plugins is provided. All classes named therein (without the mandatory Class::DBI::Plugin prefix) will be required and imported into Email::Store::DBI.

Also I've take the liberty to remove the overloading of 'bool' that is done automatically by CDBI and would cause $c->model( 'XXX' ) to fail.

Upgrading relationships is dependent on an internal Class::DBI structure called '__meta_info'. This structure might change in the future or might already have changed in the course of CDBI development, so be prepared to experience breakage if this model is used with any version of Class::DBI except 3.0.1.

I also suggest that you keep your Email::Store tables in their own database and separate from your other tables

METHODS

new

Initializes Email::Store::DBI and loads model classes according to Email::Store->plugins. Actually it reimplements the plugin mechanism of Email::Store so you are on your own if you rely on modifications to this class itself. Also attempts to borg all the classes.

BUGS

Probably many as this is the initial release.

SEE ALSO

Catalyst, Email::Store

AUTHOR

Sebastian Willert <willert@cpan.org>

Many thanks to Brian Cassidy <bricas@cpan.org> for inspiration and help with bringing this class to CPAN.

COPYRIGHT

Copyright (C) 2005 by Sebastian Willert

This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.