From: Peter Rabbitson Date: Tue, 19 Apr 2016 10:54:46 +0000 (+0200) Subject: After 5e0eea35 we can actually test for cleaned namespaces within CDBI X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=51ec03826afb5b20a686a7303bc55c42f4715945;p=dbsrgits%2FDBIx-Class-Historic.git After 5e0eea35 we can actually test for cleaned namespaces within CDBI --- diff --git a/lib/DBIx/Class/CDBICompat/AttributeAPI.pm b/lib/DBIx/Class/CDBICompat/AttributeAPI.pm index c847a39..1e76186 100644 --- a/lib/DBIx/Class/CDBICompat/AttributeAPI.pm +++ b/lib/DBIx/Class/CDBICompat/AttributeAPI.pm @@ -11,7 +11,7 @@ sub _attrs { return @{$self->{_column_data}}{@atts}; } -*_attr = \&_attrs; +sub _attr { shift->_attrs(@_) } sub _attribute_store { my $self = shift; diff --git a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm index 44a6010..c5623ca 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm @@ -137,15 +137,11 @@ sub _mk_group_accessors { ($name, $field) = @$field if ref $field; - my $accessor = $class->$maker($group, $field); - my $alias = "_${name}_accessor"; - - # warn " $field $alias\n"; - { - no strict 'refs'; - - $class->_deploy_accessor($name, $accessor); - $class->_deploy_accessor($alias, $accessor); + for( $name, "_${name}_accessor" ) { + $class->_deploy_accessor( + $_, + $class->$maker($group, $field, $_) + ); } } } diff --git a/lib/DBIx/Class/CDBICompat/Constructor.pm b/lib/DBIx/Class/CDBICompat/Constructor.pm index 65ce576..78c6d33 100644 --- a/lib/DBIx/Class/CDBICompat/Constructor.pm +++ b/lib/DBIx/Class/CDBICompat/Constructor.pm @@ -8,6 +8,7 @@ use base 'DBIx::Class::CDBICompat::ImaDBI'; use Carp; use DBIx::Class::_Util qw(quote_sub perlstring); +use namespace::clean; __PACKAGE__->set_sql(Retrieve => <<''); SELECT __ESSENTIAL__ diff --git a/lib/DBIx/Class/CDBICompat/Copy.pm b/lib/DBIx/Class/CDBICompat/Copy.pm index ec2e9ca..59780e6 100644 --- a/lib/DBIx/Class/CDBICompat/Copy.pm +++ b/lib/DBIx/Class/CDBICompat/Copy.pm @@ -7,6 +7,7 @@ use warnings; use base 'DBIx::Class'; use Carp; +use namespace::clean; =head1 NAME diff --git a/lib/DBIx/Class/CDBICompat/ImaDBI.pm b/lib/DBIx/Class/CDBICompat/ImaDBI.pm index 7a88d15..ee9aae0 100644 --- a/lib/DBIx/Class/CDBICompat/ImaDBI.pm +++ b/lib/DBIx/Class/CDBICompat/ImaDBI.pm @@ -4,10 +4,12 @@ package # hide from PAUSE use strict; use warnings; use DBIx::ContextualFetch; -use DBIx::Class::_Util qw(quote_sub perlstring); use base 'DBIx::Class'; +use DBIx::Class::_Util qw(quote_sub perlstring); +use namespace::clean; + __PACKAGE__->mk_classdata('sql_transformer_class' => 'DBIx::Class::CDBICompat::SQLTransformer'); diff --git a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm index 970b2d9..de17f97 100644 --- a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm +++ b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm @@ -5,6 +5,7 @@ use strict; use warnings; use Scalar::Util qw/weaken/; +use namespace::clean; use base 'DBIx::Class'; diff --git a/lib/DBIx/Class/CDBICompat/Pager.pm b/lib/DBIx/Class/CDBICompat/Pager.pm index c8f76fe..7316d9d 100644 --- a/lib/DBIx/Class/CDBICompat/Pager.pm +++ b/lib/DBIx/Class/CDBICompat/Pager.pm @@ -10,7 +10,7 @@ use warnings FATAL => 'all'; use base 'DBIx::Class'; -*pager = \&page; +sub pager { shift->page(@_) } sub page { my $class = shift; diff --git a/lib/DBIx/Class/CDBICompat/Relationship.pm b/lib/DBIx/Class/CDBICompat/Relationship.pm index f9d0769..54962cd 100644 --- a/lib/DBIx/Class/CDBICompat/Relationship.pm +++ b/lib/DBIx/Class/CDBICompat/Relationship.pm @@ -7,6 +7,7 @@ use warnings; use base 'DBIx::Class'; use DBIx::Class::_Util 'quote_sub'; +use namespace::clean; =head1 NAME diff --git a/lib/DBIx/Class/CDBICompat/Relationships.pm b/lib/DBIx/Class/CDBICompat/Relationships.pm index abd6783..658305d 100644 --- a/lib/DBIx/Class/CDBICompat/Relationships.pm +++ b/lib/DBIx/Class/CDBICompat/Relationships.pm @@ -9,6 +9,7 @@ use Clone; use DBIx::Class::CDBICompat::Relationship; use Scalar::Util 'blessed'; use DBIx::Class::_Util qw(quote_sub perlstring); +use namespace::clean; __PACKAGE__->mk_classdata('__meta_info' => {}); diff --git a/lib/DBIx/Class/CDBICompat/TempColumns.pm b/lib/DBIx/Class/CDBICompat/TempColumns.pm index 3a111ee..9783d6a 100644 --- a/lib/DBIx/Class/CDBICompat/TempColumns.pm +++ b/lib/DBIx/Class/CDBICompat/TempColumns.pm @@ -6,6 +6,7 @@ use warnings; use base 'DBIx::Class'; use Carp; +use namespace::clean; __PACKAGE__->mk_classdata('_temp_columns' => { }); diff --git a/xt/extra/internals/namespaces_cleaned.t b/xt/extra/internals/namespaces_cleaned.t index 3f70262..01650d5 100644 --- a/xt/extra/internals/namespaces_cleaned.t +++ b/xt/extra/internals/namespaces_cleaned.t @@ -65,8 +65,7 @@ my @modules = grep { # have an exception table for old and/or weird code we are not sure # we *want* to clean in the first place my $skip_idx = { map { $_ => 1 } ( - (grep { /^DBIx::Class::CDBICompat/ } @modules), # too crufty to touch - 'SQL::Translator::Producer::DBIx::Class::File', # ditto + 'SQL::Translator::Producer::DBIx::Class::File', # too crufty to touch # not sure how to handle type libraries 'DBIx::Class::Storage::DBI::Replicated::Types', @@ -146,6 +145,9 @@ for my $mod (@modules) { # exception time if ( ( $name eq 'import' and $via = 'Exporter' ) + or + # jesus christ nobody had any idea how to design an interface back then + ( $name =~ /_trigger/ and $via = 'Class::Trigger' ) ) { pass("${mod}::${name} is a valid uncleaned import from ${name}"); }