fix bug with result class methods being cached on in a closure instead of the object...
Rafael Kitover [Sat, 22 Jan 2011 15:22:10 +0000 (10:22 -0500)]
Changes
lib/DBIx/Class/Schema/Loader/Base.pm

diff --git a/Changes b/Changes
index e6d071a..2202f0b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - fix bug with result class methods being cached on in a closure instead
+          of the object, which breaks for multiple dynamic schemas in a single
+          perl instance
+
 0.07003  2011-01-21 06:43:05
         - fix relname/method collisions (RT#62648)
         - fix fully qualified component classes (RT#62624)
index 48b6cd5..da225f2 100644 (file)
@@ -89,6 +89,7 @@ __PACKAGE__->mk_group_accessors('simple', qw/
                                 rel_collision_map
                                 real_dump_directory
                                 datetime_undef_if_invalid
+                                _result_class_methods
 /);
 
 =head1 NAME
@@ -1576,33 +1577,32 @@ sub _make_src_class {
     $self->_inject($table_class, @{$self->additional_base_classes});
 }
 
-{
-    my %result_methods;
-
-    sub _is_result_class_method {
-        my ($self, $name) = @_;
+sub _is_result_class_method {
+    my ($self, $name) = @_;
 
-        %result_methods || do {
-            my @methods;
-            my $base       = $self->result_base_class || 'DBIx::Class::Core';
-            my @components = map { /^\+/ ? substr($_,1) : "DBIx::Class::$_" } @{ $self->components || [] };
+    if (not $self->_result_class_methods) {
+        my (@methods, %methods);
+        my $base       = $self->result_base_class || 'DBIx::Class::Core';
+        my @components = map { /^\+/ ? substr($_,1) : "DBIx::Class::$_" } @{ $self->components || [] };
 
-            for my $class ($base, @components, $self->use_moose ? 'Moose::Object' : ()) {
-                load_class $class;
+        for my $class ($base, @components, $self->use_moose ? 'Moose::Object' : ()) {
+            load_class $class;
 
-                push @methods, @{ Class::Inspector->methods($class) || [] };
-            }
+            push @methods, @{ Class::Inspector->methods($class) || [] };
+        }
 
-            push @methods, @{ Class::Inspector->methods('UNIVERSAL') };
+        push @methods, @{ Class::Inspector->methods('UNIVERSAL') };
 
-            @result_methods{@methods} = ();
+        @methods{@methods} = ();
 
-            # futureproof meta
-            $result_methods{meta} = undef;
-        };
+        # futureproof meta
+        $methods{meta} = undef;
 
-        return exists $result_methods{$name};
+        $self->_result_class_methods(\%methods);
     }
+    my $result_methods = $self->_result_class_methods;
+
+    return exists $result_methods->{$name};
 }
 
 sub _resolve_col_accessor_collisions {