[Bps-public-commit] r12474 - in Prophet/branches/moose: .

sartak at bestpractical.com sartak at bestpractical.com
Sat May 17 07:41:35 EDT 2008


Author: sartak
Date: Sat May 17 07:41:35 2008
New Revision: 12474

Modified:
   Prophet/branches/moose/   (props changed)
   Prophet/branches/moose/lib/Prophet/ReplicaExporter.pm

Log:
 r56215 at onn:  sartak | 2008-05-17 07:41:26 -0400
 Moosify ReplicaExporter


Modified: Prophet/branches/moose/lib/Prophet/ReplicaExporter.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/ReplicaExporter.pm	(original)
+++ Prophet/branches/moose/lib/Prophet/ReplicaExporter.pm	Sat May 17 07:41:35 2008
@@ -1,13 +1,32 @@
-use warnings;
-use strict;
-
 package Prophet::ReplicaExporter;
-use base qw/Class::Accessor/;
+use Moose;
 use Params::Validate qw(:all);
 use Path::Class;
 use UNIVERSAL::require;
 
-__PACKAGE__->mk_accessors(qw( source_replica target_path target_replica));
+has source_replica => (
+    is  => 'rw',
+    isa => 'Prophet::Replica',
+);
+
+has target_path => (
+    is        => 'rw',
+    isa       => 'Path::Class::Dir',
+    predicate => 'has_target_path',
+);
+
+has target_replica => (
+    is      => 'rw',
+    isa     => 'Prophet::Replica',
+    lazy    => 1,
+    default => sub {
+        my $self = shift;
+        confess "No target_path specified." unless $self->has_target_path;
+        my $replica = Prophet::Replica->new({url => "prophet:file://" . $self->target_path});
+        $replica->initialize;
+        return $replica;
+    },
+);
 
 =head1 NAME
 
@@ -156,12 +175,6 @@
 sub export {
     my $self = shift;
 
-    $self->target_replica(
-        Prophet::Replica->new(
-            { url => "prophet:file://" . $self->target_path }
-        )
-    );
-    $self->target_replica->initialize();
     $self->_init_export_metadata();
     $self->export_records( type => $_ )
         for ( @{ $self->source_replica->list_types } );
@@ -214,4 +227,7 @@
     close($cs_file);
 }
 
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
 1;



More information about the Bps-public-commit mailing list