[Bps-public-commit] r16339 - in Prophet/trunk: .

jesse at bestpractical.com jesse at bestpractical.com
Fri Oct 17 22:17:10 EDT 2008


Author: jesse
Date: Fri Oct 17 22:17:09 2008
New Revision: 16339

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

Log:
 r46998 at 31b:  jesse | 2008-10-17 23:06:32 +0100
 * switching our implementation of imutable
 


Modified: Prophet/trunk/lib/Prophet/CLI/Command.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command.pm	Fri Oct 17 22:17:09 2008
@@ -79,7 +79,7 @@
 If the optional ordering argument is specified, hash keys will be presented
 in that order (with unspecified elements following) for edit.
 
-If the record class for the current type defines a C<props_not_to_edit>
+If the record class for the current type defines a C<immutable_props>
 routine, those props will not be presented for editing.
 
 False values are not returned unless a prop is removed from the output.
@@ -93,7 +93,7 @@
     my $hash = $args{'hash'};
     my @ordering = @{ $args{'ordering'} || [] };
     my $record = $self->_get_record_object;
-    my $do_not_edit = $record->can('props_not_to_edit') ? $record->props_not_to_edit : '';
+    my @do_not_edit = $record->can('immutable_props') ? $record->immutable_props : ();
 
     if (@ordering) {
         # add any keys not in @ordering to the end of it
@@ -105,7 +105,8 @@
     }
 
     # filter out props we don't want to present for editing
-    @ordering = grep { !/$do_not_edit/ } @ordering;
+    my %do_not_edit = map { $_ => 1 } @do_not_edit;
+    @ordering = grep { !$do_not_edit{$_}  } @ordering;
 
     my $input = join "\n", map { "$_: $hash->{$_}" } @ordering;
 
@@ -127,7 +128,7 @@
 
     # if a key is deleted intentionally, set its value to ''
     for my $prop (keys %$hash) {
-        if (!exists $filtered->{$prop} and $prop =~ !/$do_not_edit/) {
+        if (!exists $filtered->{$prop} and ! exists $do_not_edit{$prop}) {
             $filtered->{$prop} = '';
         }
     }



More information about the Bps-public-commit mailing list