using Introspectable
authorzby <zby@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
Wed, 26 Nov 2008 14:24:48 +0000 (14:24 +0000)
committerzby <zby@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
Wed, 26 Nov 2008 14:24:48 +0000 (14:24 +0000)
Makefile.PL
lib/DBIx/Class/ResultSet/RecursiveUpdate.pm
t/lib/DBSchema/Result/Dvd.pm
t/var/dvdzbr.db

index ca2968a2f01a70c888f5831a8178b666ba72f919..14b707743638af026b47b26a74fbd8da0f7ed7d4 100644 (file)
@@ -12,6 +12,7 @@ WriteMakefile(
         'Test::More' => 0,
         'version'    => 0,
         'DBIx::Class' => 0,
+        'DBIx::Class::IntrospectableM2M' => 0,
     },
     dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
     clean               => { FILES => 'DBIx-Class-ResultSet-RecursiveUpdate-*' },
index 2dc40cba4f7ba698cddb0b5befa90d60a1420249..ebdfbf8abe91a3a8ab3cb4714b8d8fdb36a91f07 100644 (file)
@@ -88,9 +88,14 @@ sub recursive_update {
 
 sub is_m2m {
     my( $self, $relation ) = @_;
+    my $rclass = $self->result_class;
+    # DBIx::Class::IntrospectableM2M
+    if( $rclass->can( '_m2m_metadata' ) ){
+        return $rclass->_m2m_metadata->{$relation};
+    }
     my $object = $self->new({});
     if ( $object->can($relation) and 
-        !$object->result_source->has_relationship($relation) and 
+        !$self->result_source->has_relationship($relation) and 
         $object->can( 'set_' . $relation)
     ){
         return 1;
@@ -100,6 +105,17 @@ sub is_m2m {
 
 sub get_m2m_source {
     my( $self, $relation ) = @_;
+    my $rclass = $self->result_class;
+    # DBIx::Class::IntrospectableM2M
+    if( $rclass->can( '_m2m_metadata' ) ){
+        return $self->result_source
+        ->related_source( 
+            $rclass->_m2m_metadata->{$relation}{relation}
+        )
+        ->related_source( 
+            $rclass->_m2m_metadata->{$relation}{foreign_relation} 
+        );
+    }
     my $object = $self->new({});
     my $r = $object->$relation;
     return $r->result_source;
index d87147c24575e74695d65aec3a80a2ecaf8106c0..4908080ee9893275207e91b7d690fae134eb6875 100644 (file)
@@ -9,7 +9,7 @@ use base 'DBIx::Class';
 use overload '""' => sub {$_[0]->name}, fallback => 1;
 
 use lib '../../DBIx-Class-HTML-FormFu/lib/';
-__PACKAGE__->load_components('Core');
+__PACKAGE__->load_components(qw/IntrospectableM2M Core/);
 __PACKAGE__->table('dvd');
 __PACKAGE__->add_columns(
   'id' => {
index 1aad3b8639d1fc2c0e4101420ab2033122e63c01..3ff59f1999dc5104f523c8d5457ec841914a5072 100644 (file)
Binary files a/t/var/dvdzbr.db and b/t/var/dvdzbr.db differ
This page took 0.023141 seconds and 4 git commands to generate.