From: Peter Rabbitson Date: Sun, 15 May 2016 14:38:59 +0000 (+0200) Subject: Clean up the mess around $rsrc->sqlt_deploy_callback X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=59806d8681635c59ad3fa30c366d811291c84e87;p=dbsrgits%2FDBIx-Class-Historic.git Clean up the mess around $rsrc->sqlt_deploy_callback Back in f89bb832 nothingmuch introduced a hook point used to better integrate with KiokuDB::Backend::DBI. It was properly implemented as a $rsrc instance attribute, though somewhat undocmented. Then in 880c075b castaway came along and incorrectly documented the attribute as settable from a class, without it ever becoming a member of the list in DBIC::ResultSourceProxy. Then in 3b4e619d1 yours truly came along and (either misled by the docs, or by drugs, or both) switched the accessor to classdata (CAG inherited) even though rsrc-class-level operations were never a thing. Revert part of 3b4e619d1 and fix the documentation to properly reflect the state of affairs --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index aacf125..14e07d3 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -20,7 +20,7 @@ __PACKAGE__->mk_group_accessors(simple => qw/ source_name name source_info _ordered_columns _columns _primaries _unique_constraints _relationships resultset_attributes - column_info_from_storage + column_info_from_storage sqlt_deploy_callback /); __PACKAGE__->mk_group_accessors(component_class => qw/ @@ -28,8 +28,6 @@ __PACKAGE__->mk_group_accessors(component_class => qw/ result_class /); -__PACKAGE__->mk_classaccessor( sqlt_deploy_callback => 'default_sqlt_deploy_hook' ); - =head1 NAME DBIx::Class::ResultSource - Result source object @@ -129,6 +127,7 @@ sub new { $new->{_relationships} = { %{$new->{_relationships}||{}} }; $new->{name} ||= "!!NAME NOT SET!!"; $new->{_columns_info_loaded} ||= 0; + $new->{sqlt_deploy_callback} ||= 'default_sqlt_deploy_hook'; return $new; } @@ -942,11 +941,11 @@ sub unique_constraint_columns { =back - __PACKAGE__->sqlt_deploy_callback('mycallbackmethod'); + __PACKAGE__->result_source_instance->sqlt_deploy_callback('mycallbackmethod'); or - __PACKAGE__->sqlt_deploy_callback(sub { + __PACKAGE__->result_source_instance->sqlt_deploy_callback(sub { my ($source_instance, $sqlt_table) = @_; ... } );