[Jifty-commit] r3556 - in apps/CASPlus/trunk: lib/CASPlus/Model

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Jun 26 09:15:02 EDT 2007


Author: sterling
Date: Tue Jun 26 09:15:02 2007
New Revision: 3556

Modified:
   apps/CASPlus/trunk/   (props changed)
   apps/CASPlus/trunk/lib/CASPlus/Model/ProfileRelationship.pm

Log:
 r7749 at dynpc145:  andrew | 2007-06-20 13:30:32 -0500
  * Added the record_class method to the ProfileRelationship model returning the
    fully qualified class name of the link table, if it exists.
  * Updated the way various related_to_class settings were given to fix bugs.


Modified: apps/CASPlus/trunk/lib/CASPlus/Model/ProfileRelationship.pm
==============================================================================
--- apps/CASPlus/trunk/lib/CASPlus/Model/ProfileRelationship.pm	(original)
+++ apps/CASPlus/trunk/lib/CASPlus/Model/ProfileRelationship.pm	Tue Jun 26 09:15:02 2007
@@ -247,6 +247,7 @@
             model_class     => $link_table,
             name            => 'parent',
             refers_to_class => $args->{relation_parent}->record_class,
+            storage_type    => 'int',
         );
 
         # Create the link table child column
@@ -255,6 +256,7 @@
             model_class     => $link_table,
             name            => 'child',
             refers_to_class => $args->{relation_child}->record_class,
+            storage_type    => 'int',
         );
 
         # Create the relationship to the children via the link table
@@ -262,8 +264,9 @@
         $parent_column->create(
             model_class     => $args->{relation_parent}->model_class,
             name            => $child_name,
-            refers_to_class => $link_table->name . 'Collection',
+            refers_to_class => $link_table->qualified_class->collection_class,
             refers_to_by    => 'parent',
+            storage_type    => 'int',
         );
 
         # Create the relationship to the parents via the link table
@@ -271,8 +274,9 @@
         $child_column->create(
             model_class     => $args->{relation_child}->model_class,
             name            => $parent_name,
-            refers_to_class => $link_table->name . 'Collection',
+            refers_to_class => $link_table->qualified_class->collection_class,
             refers_to_by    => 'child',
+            storage_type    => 'int',
         );
 
         # Associate all these tables and columns with the new object
@@ -294,7 +298,7 @@
             $child_column->create(
                 model_class     => $args->{relation_child}->model_class,
                 name            => $parent_name,
-                refers_to_class => $args->{relation_parent}->record_class . 'Collection',
+                refers_to_class => $args->{relation_parent}->record_class->collection_class,
                 refers_to_by    => $child_name,
             );
         }
@@ -316,7 +320,7 @@
             $parent_column->create(
                 model_class     => $args->{relation_parent}->model_class,
                 name            => $child_name,
-                refers_to_class => $args->{relation_child}->record_class . 'Collection',
+                refers_to_class => $args->{relation_child}->record_class->collection_class,
                 refers_to_by    => $parent_name,
             );
         }
@@ -364,6 +368,30 @@
     return 1;
 }
 
+=head2 after_create
+
+Associate a C<before_set_column_name> trigger with the new columns to handle role caching.
+
+=cut
+
+# XXX TODO FIXME Add after_create()
+
+=head2 record_class
+
+Returns the record class of the L</link_table>, if this is a many-to-many relationship. Otherwise, it returns C<undef>.
+
+=cut
+
+sub record_class {
+    my $self = shift;
+
+    if (defined $self->link_table) {
+        return $self->link_table->qualified_class;
+    }
+
+    return undef;
+}
+
 =head1 AUTHOR
 
 Andrew Sterling Hanenkamp, C<< <hanenkamp at cpan.org> >>


More information about the Jifty-commit mailing list