[Bast-commits] r4710 -
DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Fri Aug 1 05:15:19 BST 2008
Author: matthewt
Date: 2008-08-01 05:15:17 +0100 (Fri, 01 Aug 2008)
New Revision: 4710
Modified:
DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm
Log:
more refacoring
Modified: DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm
===================================================================
--- DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm 2008-08-01 03:41:59 UTC (rev 4709)
+++ DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm 2008-08-01 04:15:17 UTC (rev 4710)
@@ -10,7 +10,7 @@
__PACKAGE__->mk_classdata('journal_deploy_on_connect');
__PACKAGE__->mk_classdata('journal_sources'); ## [ source names ]
__PACKAGE__->mk_classdata('journal_user'); ## [ class, field for user id ]
-__PACKAGE__->mk_classdata('journal_single_schema');
+__PACKAGE__->mk_classdata('journal_copy_sources');
__PACKAGE__->mk_classdata('__journal_schema_prototype');
__PACKAGE__->mk_classdata('_journal_schema'); ## schema object for journal
__PACKAGE__->mk_classdata('journal_component');
@@ -47,13 +47,28 @@
{
return $proto;
}
- $self->__journal_schema_prototype
+ my $proto = $self->__journal_schema_prototype
(
DBIx::Class::Schema::Journal::DB->compose_namespace
(
- blessed($self) . '::Journal'
+ (blessed($self)||$self) . '::Journal'
)
);
+ my $comp = $self->journal_component || "Journal";
+
+ ## Create auditlog+history per table
+ my %j_sources = map { $_ => 1 } $self->journal_sources
+ ? @{$self->journal_sources}
+ : $self->sources;
+
+ foreach my $s_name ($self->sources)
+ {
+ next unless($j_sources{$s_name});
+ $self->create_journal_for($s_name => $proto);
+ $self->class($s_name)->load_components($comp);
+# print STDERR "$s_name :", $self->class($s_name), "\n";
+ }
+ return $proto;
}
sub connection
@@ -63,7 +78,7 @@
# print STDERR join(":", $self->sources), "\n";
- my $journal_schema = $self->_journal_schema_prototype;
+ my $journal_schema = (ref $self||$self)->_journal_schema_prototype->clone;
if($self->journal_connection)
{
@@ -78,21 +93,7 @@
$self->_journal_schema($journal_schema);
- my $comp = $self->journal_component || "Journal";
- ## Create auditlog+history per table
- my %j_sources = map { $_ => 1 } $self->journal_sources
- ? @{$self->journal_sources}
- : $self->sources;
-
- foreach my $s_name ($self->sources)
- {
- next unless($j_sources{$s_name});
- $self->create_journal_for($s_name);
- $self->class($s_name)->load_components($comp);
-# print STDERR "$s_name :", $self->class($s_name), "\n";
- }
-
if ( $self->journal_nested_changesets ) {
$self->_journal_schema->nested_changesets(1);
die "FIXME nested changeset schema not yet supported... add parent_id to ChangeSet here";
@@ -132,19 +133,24 @@
sub create_journal_for
{
- my ($self, $s_name) = @_;
+ my ($self, $s_name, $journal_schema) = @_;
my $source = $self->source($s_name);
foreach my $audit (qw(AuditLog AuditHistory)) {
my $audit_source = join("", $s_name, $audit);
- my $class = blessed($self->_journal_schema) . "::$audit_source";
+ my $class = blessed($journal_schema) . "::$audit_source";
DBIx::Class::Componentised->inject_base($class, "DBIx::Class::Schema::Journal::DB::$audit");
$class->journal_define_table($source);
- $self->_journal_schema->register_class($audit_source, $class);
+ $journal_schema->register_class($audit_source, $class);
+
+ if ($self->journal_copy_sources)
+ {
+ $self->register_class($audit_source, $class);
+ }
}
}
More information about the Bast-commits
mailing list