Fix DBIC::Schema->compose_namespace POD link
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / TraitFor / Model / DBIC / Schema / Replicated.pm
index e62250a..682e468 100644 (file)
@@ -1,13 +1,19 @@
 package Catalyst::TraitFor::Model::DBIC::Schema::Replicated;
 
+## WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
+## If you make changes to this code and don't actually go and test it
+## on a real replicated environment I will rip you an new hole.  The
+## test suite DOES NOT properly test this.  --JNAP
+
 use namespace::autoclean;
 use Moose::Role;
-use Moose::Autobox;
 use Carp::Clan '^Catalyst::Model::DBIC::Schema';
 
 use Catalyst::Model::DBIC::Schema::Types qw/ConnectInfos LoadedClass/;
 use MooseX::Types::Moose qw/Str HashRef/;
 
+use Module::Runtime;
+
 =head1 NAME
 
 Catalyst::TraitFor::Model::DBIC::Schema::Replicated - Replicated storage support for
@@ -75,6 +81,9 @@ has replicants => (
     is => 'ro', isa => ConnectInfos, coerce => 1, required => 1
 );
 
+# If you change LoadedClass with LoadableClass I will rip you a new hole,
+# it doesn't work exactly the same - JNAP
+
 has pool_type => (is => 'ro', isa => LoadedClass);
 has pool_args => (is => 'ro', isa => HashRef);
 has balancer_type => (is => 'ro', isa => Str);
@@ -89,6 +98,11 @@ after setup => sub {
             "DBIx::Class::Storage$storage_type"
             : $storage_type;
 
+            # For some odd reason if you try to use 'use_module' as an export
+            # the code breaks.  I guess something odd about MR and all these
+            # runtime loaded crazy trait code.  Please don't "tidy the code up" -JNAP
+            Module::Runtime::use_module($class);
+
         croak "This storage_type cannot be used with replication"
             unless $class->isa('DBIx::Class::Storage::DBI::Replicated');
     } else {
@@ -118,7 +132,7 @@ sub BUILD {}
 after BUILD => sub {
     my $self = shift;
 
-    $self->storage->connect_replicants(map [ $_ ], $self->replicants->flatten);
+    $self->storage->connect_replicants(map [ $_ ], @{ $self->replicants });
 };
 
 =head1 SEE ALSO
@@ -129,10 +143,15 @@ L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>
 
 =head1 AUTHOR
 
-Rafael Kitover, C<rkitover at cpan.org>
+See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
+L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
 
 =head1 COPYRIGHT
 
+See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
+
+=head1 LICENSE
+
 This program is free software, you can redistribute it and/or modify it
 under the same terms as Perl itself.