Matthew Lawrence > Class-DBI-ViewLoader-0.05 > Class::DBI::ViewLoader::Auto

Download:
Class-DBI-ViewLoader-0.05.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Class::DBI::ViewLoader::Auto - Load views for existing Class::DBI classes

SYNOPSIS ^

    package MyMovieClass;

    use strict;
    use warnings;

    use Class::DBI;
    use Class::DBI::ViewLoader::Auto;

    our @ISA = qw( Class::DBI );

    __PACKAGE__->connection('dbi:Pg:dbname=mymoviedb', 'me', 'mypasswd');

    # load views from database mymoviedb to MyMovieClass::*
    @loaded = __PACKAGE__->load_views();

    # load only views starting with film_
    @loaded = __PACKAGE__->load_views(qr/^film_/);

    # or pass more options:
    @loaded = __PACKAGE__->load_views(
            namespace => 'MyMovieClass::View',
            exclude => qr(^test_),
        );

DESCRIPTION

This module provides a simpler interface to Class::DBI::ViewLoader.

EXPORTS ^

This module exports the load_views method into the calling package

METHODS ^

load_views

    $loader = $cdbi_class->load_views( %opts or $include )

Loads views from the database connection in $cdbi_class.

The default namespace is the same as the calling class.

%opts is passed to the Class::DBI::Loader constructor. If a scalar argument is given instead of a hash or hashref, it is interpreted as being the include pattern.

The options dsn, username, password and options are silently ignored.

$cdbi_class should always be the leftmost base class of the generated classes. base_classes and left_base_classes options are supported, but it might make more sense to add those bases to the calling class manually.

Returns the same as Class::DBI::ViewLoader->load_views, i.e. a list of loaded classes.

DIAGNOSTICS ^

%s has no connection

The given class had no connection set up to read views from.

syntax highlighting: