From: Arthur Axel 'fREW' Schmidt Date: Tue, 18 May 2010 04:35:03 +0000 (-0500) Subject: better cookbook entry X-Git-Tag: v0.001000_10~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e80ef6bcfb241e2ab6969e6e8f36259e0bd485c8;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git better cookbook entry --- diff --git a/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod b/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod index b1bba7e..fed4a9f 100644 --- a/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod +++ b/lib/DBIx/Class/DeploymentHandler/Cookbook/CustomResultSource.pod @@ -1,11 +1,21 @@ - package MyApp::Schema::JournalStorage; +=pod + +One of the reasons for the absurd level of flexibility that +L is so that you can do things that we did not +originally anticipate. Surprisingly, I never added a method to change the +table for the version storage. That's fine though, the following recipe +shows how one can do it in style: + +=head2 Version Storage + + package MyApp::Schema::DBICDHStorage; use Moose; extends 'DBIx::Class::DeploymentHandler::VersionStorage::Standard'; sub _build_version_rs { $_[0]->schema->register_class( __VERSION => - 'FL::Bench::Schema::JournalTable' + 'MyApp::Schema::DBICDHStorageResult' ); $_[0]->schema->resultset('__VERSION') } @@ -14,12 +24,23 @@ __PACKAGE__->meta->make_immutable; 1; - package MyApp::Schema::JournalTable; +There's not a whole lot special there. The only real bit of code to point out +is the C call. We make sure to point C<__VERSION> to the +result class that we will define next. + +=head2 Version Result Class + + package MyApp::Schema::DBICDHStorageResult; use parent 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult'; __PACKAGE__->table('fl_bench_journal_versions'); 1; - package MyApp::Schema::Journal; +As you can see, this is almost silly how simple it is, we just change the +table being set on the original result. + +=head2 Our very own DeploymentHandler + + package MyApp::Schema::DeploymentHandler; use Moose; extends 'DBIx::Class::DeploymentHandler::Dad'; @@ -40,7 +61,7 @@ }, 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage', - class_name => 'MyApp::Schema::JournalStorage', + class_name => 'MyApp::Schema::DBICDHStorage', delegate_name => 'version_storage', attributes_to_assume => ['schema'], };