[Bps-public-commit] Prophet branch, master, updated. c096fd7ff607e4f3ebb7096a3fdb12d4521a28f9

Alex M Vandiver alexmv at bestpractical.com
Mon Apr 27 14:23:59 EDT 2009


The branch, master has been updated
       via  c096fd7ff607e4f3ebb7096a3fdb12d4521a28f9 (commit)
      from  2cc8f2250776d08d6d3417233b513b9119813770 (commit)

Summary of changes:
 lib/Prophet/Replica/file.pm |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit c096fd7ff607e4f3ebb7096a3fdb12d4521a28f9
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Mon Apr 27 14:23:56 2009 -0400

    Respect PROPHET_REPLICA_TYPE when creating new replicas

diff --git a/lib/Prophet/Replica/file.pm b/lib/Prophet/Replica/file.pm
index b6ffc36..f5857ac 100644
--- a/lib/Prophet/Replica/file.pm
+++ b/lib/Prophet/Replica/file.pm
@@ -11,17 +11,21 @@ sub new {
     my $class = shift;
     my %args = @_;
 
-    my @types = ('sqlite');
+    my @types = ('file','sqlite');
     unshift @types, $ENV{PROPHET_REPLICA_TYPE} if $ENV{PROPHET_REPLICA_TYPE};
-    for (@types) {
+
+    my @possible;
+    for my $type (@types) {
         my $ret = eval {
-            my $other = "Prophet::Replica::$_";
-            Prophet::App->require($other);
-            $ret = $other->new(@_);
+            my $other = "Prophet::Replica::$type";
+            Prophet::App->try_to_require($other);
+            $ret = $type eq "file" ? $other->SUPER::new(@_) : $other->new(@_);
         };
-        return $ret if not $@ and $ret and $ret->replica_exists;
+        next if $@ or not $ret;
+        return $ret if $ret->replica_exists;
+        push @possible, $ret;
     }
-    return $class->SUPER::new(@_);
+    return $possible[0];
 }
 
 1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list