[Bps-public-commit] r14411 - in Prophet/trunk: . lib/Prophet/CLI/Command

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 22 23:05:31 EDT 2008


Author: sartak
Date: Tue Jul 22 23:05:31 2008
New Revision: 14411

Added:
   Prophet/trunk/lib/Prophet/CLI/CollectionCommand.pm
Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI/Command/Search.pm

Log:
 r64773 at onn:  sartak | 2008-07-22 23:04:12 -0400
 Add a CollectionCommand class which abstracts "getting" a collection


Added: Prophet/trunk/lib/Prophet/CLI/CollectionCommand.pm
==============================================================================
--- (empty file)
+++ Prophet/trunk/lib/Prophet/CLI/CollectionCommand.pm	Tue Jul 22 23:05:31 2008
@@ -0,0 +1,24 @@
+#!/usr/bin/env perl
+package Prophet::CLI::CollectionCommand;
+use Moose::Role;
+
+sub get_collection_object {
+    my $self = shift;
+    my %args = @_;
+
+    my $class = $self->_get_record_class->collection_class;
+    Prophet::App->require_module($class);
+
+    my $records = $class->new(
+        app_handle => $self->app_handle,
+        handle     => $self->app_handle->handle,
+        type       => $args{type} || $self->type,
+    );
+
+    return $records;
+}
+
+no Moose::Role;
+
+1;
+

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Search.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Search.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Search.pm	Tue Jul 22 23:05:31 2008
@@ -2,21 +2,11 @@
 use Moose;
 extends 'Prophet::CLI::Command';
 with 'Prophet::CLI::RecordCommand';
-has '+uuid' => ( required => 0);
+with 'Prophet::CLI::CollectionCommand';
 
-sub get_collection_object {
-    my $self = shift;
-
-    my $class = $self->_get_record_class->collection_class;
-    Prophet::App->require_module($class);
-    my $records = $class->new(
-        app_handle => $self->app_handle,
-        handle => $self->app_handle->handle,
-        type   => $self->type
-    );
-
-    return $records;
-}
+has '+uuid' => (
+    required => 0,
+);
 
 sub get_search_callback {
     my $self = shift;



More information about the Bps-public-commit mailing list