[Bps-public-commit] r11476 - in SVN-PropDB: bin

clkao at bestpractical.com clkao at bestpractical.com
Thu Apr 3 23:54:37 EDT 2008


Author: clkao
Date: Thu Apr  3 23:54:37 2008
New Revision: 11476

Modified:
   SVN-PropDB/bin/sd
   SVN-PropDB/lib/Prophet/Record.pm

Log:
register_collection_reference.


Modified: SVN-PropDB/bin/sd
==============================================================================
--- SVN-PropDB/bin/sd	(original)
+++ SVN-PropDB/bin/sd	Thu Apr  3 23:54:37 2008
@@ -39,9 +39,8 @@
 #has owner
 
 __PACKAGE__->register_reference( comments => 'SVB::Collection::Comment',
-                              by => 'ticket'
-                            );
-                            
+                                 by => 'ticket'
+                               );
 package SVB::Model::Comment;
 use base qw/SVB::Record/;
 

Modified: SVN-PropDB/lib/Prophet/Record.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Record.pm	(original)
+++ SVN-PropDB/lib/Prophet/Record.pm	Thu Apr  3 23:54:37 2008
@@ -52,7 +52,26 @@
 
 sub record_type { $_[0]->type }
 
-=head2 register_reference $accessor, $collection_class, by => $key_in_model
+=head2 register_reference
+
+=cut
+
+sub register_reference {
+    my ($class, $accessor, $foreign_class, @args) = @_;
+    if ($foreign_class->isa('Prophet::Collection')) {
+        return $class->register_collection_reference($accessor => $foreign_class,
+                                              @args);
+    }
+    elsif ($foreign_class->isa('Prophet::Record')) {
+        warn "not yet";
+    }
+    else {
+        die "wtf";
+    }
+
+}
+
+=head2 register_collection_reference $accessor, $collection_class, by => $key_in_model
 
 Registers and create accessor in current class the associated
 collection C<$collection_class>, which refers to the current class by
@@ -60,7 +79,7 @@
 
 =cut
 
-sub register_reference {
+sub register_collection_reference {
     my ($class, $accessor, $collection_class, @args) = @_;
     my %args = validate( @args, { by => 1 });
     no strict 'refs';



More information about the Bps-public-commit mailing list