And the extra main classes
Matt S Trout [Mon, 2 Jan 2006 18:08:32 +0000 (18:08 +0000)]
lib/DBIx/Class/Relationship/Helpers.pm [new file with mode: 0644]
lib/DBIx/Class/Relationship/ManyToMany.pm [new file with mode: 0644]

diff --git a/lib/DBIx/Class/Relationship/Helpers.pm b/lib/DBIx/Class/Relationship/Helpers.pm
new file mode 100644 (file)
index 0000000..e4a28d7
--- /dev/null
@@ -0,0 +1,15 @@
+package DBIx::Class::Relationship::Helpers;
+
+use strict;
+use warnings;
+
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(qw/
+    Relationship::HasMany
+    Relationship::HasOne
+    Relationship::BelongsTo
+    Relationship::ManyToMany
+/);
+
+1;
diff --git a/lib/DBIx/Class/Relationship/ManyToMany.pm b/lib/DBIx/Class/Relationship/ManyToMany.pm
new file mode 100644 (file)
index 0000000..09fd212
--- /dev/null
@@ -0,0 +1,19 @@
+package DBIx::Class::Relationship::ManyToMany;
+
+use strict;
+use warnings;
+
+sub many_to_many {
+  my ($class, $meth, $rel_class, $f_class) = @_;
+  
+  eval "require $f_class";
+  
+  {
+    no strict 'refs';
+    no warnings 'redefine';
+    *{"${class}::${meth}"} =
+      sub { shift->search_related($rel_class)->search_related($f_class, @_); };
+  }
+}
+
+1;