| CatalystX-Usul documentation | Contained in the CatalystX-Usul distribution. |
CatalystX::Usul::Model::Schema - Base class for database models
0.3.$Revision: 583 $
package YourApp::Model::YourModel;
use base qw(CatalystX::Usul::Model::Schema);
__PACKAGE__->config
( connect_info => [],
database => q(library),
schema_class => q(YourApp::Schema::YourSchema) );
sub new {
my ($class, $app, @rest) = @_;
my $database = $rest[0]->{database} || $class->config->{database};
$class->config( connect_info
=> $class->connect_info( $app, $database ) );
return $class->next::method( $app, @rest );
}
Aggregates the methods from the three classes it inherits from
Adds the attributes from CatalystX::Usul::Model to the ones from Catalyst::Model::DBIC::Schema
Calls parent method to obtain dsn, user and password information from configuration file before instantiating the database classes
None
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <Support at RoxSoft.co.uk>
Copyright (c) 2008 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
| CatalystX-Usul documentation | Contained in the CatalystX-Usul distribution. |
# @(#)$Id: Schema.pm 583 2009-06-12 14:17:22Z pjf $ package CatalystX::Usul::Model::Schema; use strict; use warnings; use version; our $VERSION = qv( sprintf '0.3.%d', q$Rev: 583 $ =~ /\d+/gmx ); use parent qw(Catalyst::Model::DBIC::Schema CatalystX::Usul::Model CatalystX::Usul::Schema); use Class::C3; sub build_per_context_instance { my ($self, $c, @rest) = @_; my $new = $self->next::method( $c, @rest ); my $model = $c->model( q(Base) ); $new->{ $_ } = $model->{ $_ } for (keys %{ $model }); return $new; } sub connect_info { my ($self, $app, $db) = @_; my ($args, $dir, $info, $path); if ($db and $dir = $app->config->{ctrldir}) { $path = $self->catfile( $dir, $app->config->{prefix}.q(.txt) ); $args = { seed => $app->config->{secret} || $app->config->{prefix} }; $args->{data} = $self->io( $path )->all if (-f $path); $info = $self->next::method( $self->catfile( $dir, $db.q(.xml) ), $db, $args ); } else { $app->log->error( "${self}: No database or directory\n" ) } return $info; } 1; __END__
# Local Variables: # mode: perl # tab-width: 3 # End: