From: Dan Kubb Date: Thu, 25 Aug 2005 08:49:56 +0000 (+0000) Subject: Slowly integrating Fields with CDBI Compat AccessorMapping and ColumnGroups X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=667759eaf695d4d94d4e4cbdc79e596aa2cb2d2b;p=dbsrgits%2FDBIx-Class-Historic.git Slowly integrating Fields with CDBI Compat AccessorMapping and ColumnGroups --- diff --git a/lib/DBIx/Class/CDBICompat/AccessorMapping.pm b/lib/DBIx/Class/CDBICompat/AccessorMapping.pm index d707e74..7f3ea48 100644 --- a/lib/DBIx/Class/CDBICompat/AccessorMapping.pm +++ b/lib/DBIx/Class/CDBICompat/AccessorMapping.pm @@ -35,16 +35,12 @@ sub create { my %att; foreach my $col (keys %{ $class->_columns }) { my $field = $class->get_field($col); - if ($class->can('accessor_name')) { - my $acc = $class->accessor_name($col); - $field->set_accessor_name($acc); - $att{$col} = delete $attrs->{$acc} if exists $attrs->{$acc}; - } - if ($class->can('mutator_name')) { - my $mut = $class->mutator_name($col); - $field->set_mutator_name($mut); - $att{$col} = delete $attrs->{$mut} if exists $attrs->{$mut}; - } + + my $acc = $field->get_accessor_name; + $att{$col} = delete $attrs->{$acc} if exists $attrs->{$acc}; + + my $mut = $field->get_mutator_name; + $att{$col} = delete $attrs->{$mut} if exists $attrs->{$mut}; } return $class->NEXT::ACTUAL::create({ %$attrs, %att }, @rest); } diff --git a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm index f8e1b1b..6a91fc2 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm @@ -48,18 +48,16 @@ sub _register_column_group { foreach my $col (@cols) { $groups->{$group}{$col} ||= {}; -# $class->set_field_column_name($col => $col); -# -# my $field = $class->get_field($col); -# -# if($class->can('accessor_name')) { -# $field->set_accessor_name($class->accessor_name($col)); -# } -# if($class->can('mutator_name')) { -# $field->set_mutator_name($class->mutator_name($col)); -# } -# -# $class->_columns->{$col}{field} = $field; + $class->set_field_column_name($col => $col); + + my $field = $class->get_field($col); + + if($class->can('accessor_name')) { + $field->set_accessor_name($class->accessor_name($col)); + } + if($class->can('mutator_name')) { + $field->set_mutator_name($class->mutator_name($col)); + } } #if ($group eq 'Essential') {