[Bps-public-commit] r15411 - in sd/trunk/lib/App/SD/CLI: . Model

jesse at bestpractical.com jesse at bestpractical.com
Sun Aug 24 11:53:17 EDT 2008


Author: jesse
Date: Sun Aug 24 11:53:16 2008
New Revision: 15411

Modified:
   sd/trunk/lib/App/SD/CLI/Command.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm
   sd/trunk/lib/App/SD/CLI/Model/Ticket.pm

Log:
* Extract create_new_comment to the ::CLI::Model::Ticket role and rename it to be more obvious

Modified: sd/trunk/lib/App/SD/CLI/Command.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command.pm	Sun Aug 24 11:53:16 2008
@@ -63,30 +63,6 @@
     return $content;
 }
 
-=head2 create_new_comment content => str, uuid => str
-
-A convenience method that takes a content string and a ticket uuid and creates
-a new comment record, for use in other commands (such as ticket create
-and ticket update).
-
-=cut
-
-sub create_new_comment {
-    my $self = shift;
-    validate(@_, { content => 1, uuid => 1 } );
-    my %args = @_;
-
-    require App::SD::CLI::Command::Ticket::Comment::Create;
-
-    $self->cli->change_attributes( args => \%args );
-    my $command = App::SD::CLI::Command::Ticket::Comment::Create->new(
-        uuid => $args{uuid},
-        cli => $self->cli,
-        type => 'comment',
-    );
-    $command->run();
-}
-
 no Moose::Role;
 
 1;

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm	Sun Aug 24 11:53:16 2008
@@ -54,7 +54,7 @@
         # retrieve the created record from the superclass
         $record = $self->record();
 
-        $self->create_new_comment( content => $comment, uuid => $record->uuid )
+        $self->add_comment( content => $comment, uuid => $record->uuid )
             if $comment;
 
     } else {

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm	Sun Aug 24 11:53:16 2008
@@ -63,7 +63,7 @@
 
         print 'Updated ticket ' . $record->luid . ' (' . $record->uuid . ")\n";
 
-        $self->create_new_comment( content => $comment, uuid => $record->uuid )
+        $self->add_comment( content => $comment, uuid => $record->uuid )
             if $comment;
 
     } else {

Modified: sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Model/Ticket.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Model/Ticket.pm	Sun Aug 24 11:53:16 2008
@@ -1,8 +1,34 @@
 package App::SD::CLI::Model::Ticket;
 use Moose::Role;
-
+use Params::Validate qw(:all);
 use constant record_class => 'App::SD::Model::Ticket';
 
+
+=head2 add_comment content => str, uuid => str
+
+A convenience method that takes a content string and a ticket uuid and creates
+a new comment record, for use in other commands (such as ticket create
+and ticket update).
+
+=cut
+
+sub add_comment {
+    my $self = shift;
+    validate(@_, { content => 1, uuid => 1 } );
+    my %args = @_;
+
+    require App::SD::CLI::Command::Ticket::Comment::Create;
+
+    $self->cli->mutate_attributes( args => \%args );
+    my $command = App::SD::CLI::Command::Ticket::Comment::Create->new(
+        uuid => $args{uuid},
+        cli => $self->cli,
+        type => 'comment',
+    );
+    $command->run();
+}
+
+
 =head2 comment_separator
 
 Returns a string that separates the prop: value lines from the comment,



More information about the Bps-public-commit mailing list