Move has_a() code out of ColumnCase. That should be the last of it.
Michael G Schwern [Fri, 14 Mar 2008 02:01:20 +0000 (02:01 +0000)]
lib/DBIx/Class/CDBICompat/ColumnCase.pm
lib/DBIx/Class/CDBICompat/Relationships.pm

index 410fded..a7c62a9 100644 (file)
@@ -17,10 +17,12 @@ sub add_columns {
 }
 
 sub has_a {
-  my ($class, $col, @rest) = @_;
-  $class->next::method(lc($col), @rest);
-  $class->mk_group_accessors('inflated_column' => $col);
-  return 1;
+    my($self, $col, @rest) = @_;
+    
+    $self->_declare_has_a(lc $col, @rest);
+    $self->_mk_inflated_column_accessor($col);
+    
+    return 1;
 }
 
 sub has_many {
index 77bc788..0a4b475 100644 (file)
@@ -23,8 +23,19 @@ Emulate C<has_a>, C<has_many>, C<might_have> and C<meta_info>.
 =cut
 
 sub has_a {
+    my($self, $col, @rest) = @_;
+    
+    $self->_declare_has_a($col, @rest);
+    $self->_mk_inflated_column_accessor($col);
+    
+    return 1;
+}
+
+
+sub _declare_has_a {
   my ($self, $col, $f_class, %args) = @_;
-  $self->throw_exception( "No such column ${col}" ) unless $self->has_column($col);
+  $self->throw_exception( "No such column ${col}" )
+   unless $self->has_column($col);
   $self->ensure_class_loaded($f_class);
   
   my $rel_info;
@@ -55,10 +66,15 @@ sub has_a {
     has_a => $col,
     $rel_info
   );
-  
+
   return 1;
 }
 
+sub _mk_inflated_column_accessor {
+    my($class, $col) = @_;
+    
+    return $class->mk_group_accessors('inflated_column' => $col);
+}
 
 sub has_many {
   my ($class, $rel, $f_class, $f_key, $args) = @_;