make sure various Storage mutators correctly return a useful value
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Replicated.pm
index d711f84..8d75590 100644 (file)
@@ -287,7 +287,7 @@ has 'write_handler' => (
 
 This class defines the following methods.
 
-=head2 new
+=head2 BUILDARGS
 
 L<DBIx::Class::Schema> when instantiating it's storage passed itself as the
 first argument.  So we need to massage the arguments a bit so that all the
@@ -295,10 +295,15 @@ bits get put into the correct places.
 
 =cut
 
-around 'new' => sub {
-  my ($new, $self, $schema, $storage_type_args, @args) = @_;
-  return $self->$new(schema=>$schema, %$storage_type_args, @args);
-};
+sub BUILDARGS {
+  my ($class, $schema, $storage_type_args, @args) = @_;        
+  
+  return {
+       schema=>$schema, 
+       %$storage_type_args,
+       @args
+  }
+}
 
 =head2 _build_master
 
@@ -410,6 +415,8 @@ inserted something and need to get a resultset including it, etc.
 
 =cut
 
+use Benchmark;
+
 sub execute_reliably {
   my ($self, $coderef, @args) = @_;
   
@@ -533,6 +540,7 @@ sub limit_dialect {
   foreach my $source ($self->all_storages) {
     $source->limit_dialect(@_);
   }
+  return $self->master->quote_char;
 }
 
 =head2 quote_char
@@ -546,6 +554,7 @@ sub quote_char {
   foreach my $source ($self->all_storages) {
     $source->quote_char(@_);
   }
+  return $self->master->quote_char;
 }
 
 =head2 name_sep
@@ -559,6 +568,7 @@ sub name_sep {
   foreach my $source ($self->all_storages) {
     $source->name_sep(@_);
   }
+  return $self->master->name_sep;
 }
 
 =head2 set_schema
@@ -582,9 +592,12 @@ set a debug flag across all storages
 
 sub debug {
   my $self = shift @_;
-  foreach my $source ($self->all_storages) {
-    $source->debug(@_);
+  if(@_) {
+    foreach my $source ($self->all_storages) {
+      $source->debug(@_);
+    }   
   }
+  return $self->master->debug;
 }
 
 =head2 debugobj
@@ -595,9 +608,12 @@ set a debug object across all storages
 
 sub debugobj {
   my $self = shift @_;
-  foreach my $source ($self->all_storages) {
-    $source->debugobj(@_);
+  if(@_) {
+    foreach my $source ($self->all_storages) {
+      $source->debugobj(@_);
+    }  
   }
+  return $self->master->debugobj;
 }
 
 =head2 debugfh
@@ -608,9 +624,12 @@ set a debugfh object across all storages
 
 sub debugfh {
   my $self = shift @_;
-  foreach my $source ($self->all_storages) {
-    $source->debugfh(@_);
+  if(@_) {
+    foreach my $source ($self->all_storages) {
+      $source->debugfh(@_);
+    }   
   }
+  return $self->master->debugfh;
 }
 
 =head2 debugcb
@@ -621,9 +640,12 @@ set a debug callback across all storages
 
 sub debugcb {
   my $self = shift @_;
-  foreach my $source ($self->all_storages) {
-    $source->debugcb(@_);
+  if(@_) {
+    foreach my $source ($self->all_storages) {
+      $source->debugcb(@_);
+    }   
   }
+  return $self->master->debugcb;
 }
 
 =head2 disconnect
@@ -691,4 +713,6 @@ You may distribute this code under the same terms as Perl itself.
 
 =cut
 
+__PACKAGE__->meta->make_immutable;
+
 1;