From: Matt S Trout Date: Fri, 1 Aug 2008 03:41:59 +0000 (+0000) Subject: factor journal schema proto construction out so compose_namespace only runs once X-Git-Tag: v0.900201~58 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ae5bebce395d6a1d9b9f3f1d20c5c587d739d93;p=dbsrgits%2FDBIx-Class-Journal.git factor journal schema proto construction out so compose_namespace only runs once --- diff --git a/lib/DBIx/Class/Schema/Journal.pm b/lib/DBIx/Class/Schema/Journal.pm index b1db8c2..122bbd4 100644 --- a/lib/DBIx/Class/Schema/Journal.pm +++ b/lib/DBIx/Class/Schema/Journal.pm @@ -10,6 +10,8 @@ __PACKAGE__->mk_classdata('journal_connection'); __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_schema_prototype'); __PACKAGE__->mk_classdata('_journal_schema'); ## schema object for journal __PACKAGE__->mk_classdata('journal_component'); __PACKAGE__->mk_classdata('journal_nested_changesets'); @@ -38,6 +40,22 @@ use warnings; # } +sub _journal_schema_prototype +{ + my $self = shift; + if (my $proto = $self->__journal_schema_prototype) + { + return $proto; + } + $self->__journal_schema_prototype + ( + DBIx::Class::Schema::Journal::DB->compose_namespace + ( + blessed($self) . '::Journal' + ) + ); +} + sub connection { my $self = shift; @@ -45,7 +63,7 @@ sub connection # print STDERR join(":", $self->sources), "\n"; - my $journal_schema = DBIx::Class::Schema::Journal::DB->compose_namespace(blessed($self) . '::Journal'); + my $journal_schema = $self->_journal_schema_prototype; if($self->journal_connection) {