Slowly integrating Fields with CDBI Compat AccessorMapping and ColumnGroups historic/DBIx-Class-Field_cdbicompat_integration
Dan Kubb [Thu, 25 Aug 2005 08:49:56 +0000 (08:49 +0000)]
lib/DBIx/Class/CDBICompat/AccessorMapping.pm
lib/DBIx/Class/CDBICompat/ColumnGroups.pm

index d707e74..7f3ea48 100644 (file)
@@ -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);
 }
index f8e1b1b..6a91fc2 100644 (file)
@@ -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') {