[Bps-public-commit] r14066 - in Prophet/trunk: . lib/Prophet/CLI/Command
sartak at bestpractical.com
sartak at bestpractical.com
Mon Jul 14 12:33:02 EDT 2008
Author: sartak
Date: Mon Jul 14 12:33:01 2008
New Revision: 14066
Modified:
Prophet/trunk/ (props changed)
Prophet/trunk/lib/Prophet/CLI/Command.pm
Prophet/trunk/lib/Prophet/CLI/Command/Create.pm
Prophet/trunk/lib/Prophet/CLI/Command/Update.pm
Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
Log:
r64113 at onn: sartak | 2008-07-11 11:00:28 -0400
Checkpoint: tests not fixed yet. edit_args renamed to edit_props and improved, and used better by the update command
Modified: Prophet/trunk/lib/Prophet/CLI/Command.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command.pm Mon Jul 14 12:33:01 2008
@@ -5,7 +5,11 @@
is => 'rw',
isa => 'Prophet::CLI',
weak_ref => 1,
- handles => [qw/args set_arg arg has_arg delete_arg app_handle/],
+ handles => [
+ qw/args set_arg arg has_arg delete_arg/,
+ qw/props set_prop prop has_prop delete_prop/,
+ 'app_handle',
+ ],
);
sub fatal_error {
@@ -54,39 +58,34 @@
return $filtered;
}
-=head2 edit_args [arg], defaults -> hashref
+=head2 edit_props [arg], defaults -> hashref
-Returns a hashref of the command arguments mixed in with any default arguments.
-If the "arg" argument is specified, (default "edit", use C<undef> if you only want default arguments), then L</edit_hash> is
-invoked on the argument list.
+Returns a hashref of the command's props mixed in with any default props.
+If the "arg" argument is specified, (default "edit", use C<undef> if you only want default arguments), then L</edit_hash> is invoked on the property list.
=cut
-sub edit_args {
+sub edit_props {
my $self = shift;
my $arg = shift || 'edit';
- my $edit_hash;
- if ($self->has_arg($arg)) {
- $self->delete_arg($arg);
- $edit_hash = 1;
- }
-
- my %args;
+ my %props;
if (@_ == 1) {
- %args = (%{ $self->args }, %{ $_[0] });
+ %props = (%{ $_[0] }, %{ $self->props });
}
else {
- %args = (%{ $self->args }, @_);
+ %props = (@_, %{ $self->props });
}
- if ($edit_hash) {
- return $self->edit_hash(\%args);
+ if ($self->has_arg($arg)) {
+ return $self->edit_hash(\%props);
}
- return \%args;
+ return \%props;
}
__PACKAGE__->meta->make_immutable;
no Moose;
+1;
+
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Create.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Create.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Create.pm Mon Jul 14 12:33:01 2008
@@ -7,7 +7,7 @@
sub run {
my $self = shift;
my $record = $self->_get_record_class;
- my ($val, $msg) = $record->create( props => $self->edit_args );
+ my ($val, $msg) = $record->create( props => $self->edit_props );
if (!$val) {
warn $msg ."\n";
}
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Update.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Update.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Update.pm Mon Jul 14 12:33:01 2008
@@ -7,13 +7,7 @@
my $self = shift;
my $record = shift;
- if ($self->has_arg('edit')) {
- my $props = $record->get_props;
- return $self->edit_hash($props);
- }
- else {
- return $self->args;
- }
+ return $self->edit_props('edit', $record->get_props);
}
sub run {
Modified: Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm Mon Jul 14 12:33:01 2008
@@ -2,19 +2,19 @@
use Moose::Role;
has type => (
- is => 'rw',
- isa => 'Str',
- required => 0
+ is => 'rw',
+ isa => 'Str',
+ required => 0,
);
has uuid => (
- is => 'rw',
- isa => 'Str',
- required => 0
+ is => 'rw',
+ isa => 'Str',
+ required => 0,
);
has record_class => (
- is => 'rw',
+ is => 'rw',
isa => 'Prophet::Record',
);
More information about the Bps-public-commit
mailing list