[Catalyst-commits] r11215 -
Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Sun Aug 23 02:05:23 GMT 2009
Author: caelum
Date: 2009-08-23 02:05:22 +0000 (Sun, 23 Aug 2009)
New Revision: 11215
Modified:
Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm
Log:
fix delegation for multiple schemas
Modified: Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm 2009-08-22 19:56:53 UTC (rev 11214)
+++ Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm 2009-08-23 02:05:22 UTC (rev 11215)
@@ -459,13 +459,6 @@
lazy_build => 1,
);
-# method names delegated to schema
-has _delegates => (
- is => 'ro',
- isa => ArrayRef,
- lazy_build => 1
-);
-
has _default_cursor_class => (
is => 'ro',
isa => LoadedClass,
@@ -502,7 +495,7 @@
$self->meta->add_attribute('schema',
is => 'rw',
- isa => $self->schema_class,
+ isa => 'DBIx::Class::Schema',
handles => $self->_delegates
);
@@ -590,13 +583,26 @@
return $model_name;
}
-sub _build__delegates {
+sub _delegates {
my $self = shift;
# XXX change this to CMOP once CAG is updated
my @schema_methods = @{ Class::Inspector->methods($self->schema_class) };
- my @my_methods = $self->meta->get_all_method_names;
+# combine with any already added by other schemas
+ my @handles = eval {
+ @{ $self->meta->find_attribute_by_name('schema')->handles }
+ };
+
+# now kill the attribute, otherwise add_attribute in BUILD will not do the right
+# thing. May be a Moose bug.
+ eval { $self->meta->remove_attribute('schema') };
+
+ my %schema_methods;
+ @schema_methods{ @schema_methods, @handles } = ();
+ @schema_methods = keys %schema_methods;
+
+ my @my_methods = $self->meta->get_all_method_names;
my %my_methods;
@my_methods{@my_methods} = ();
More information about the Catalyst-commits
mailing list