[Jifty-commit] r5957 - in jifty/trunk/lib/Jifty/Action: Record

Jifty commits jifty-commit at lists.jifty.org
Tue Oct 21 03:43:38 EDT 2008


Author: ruz
Date: Tue Oct 21 03:43:38 2008
New Revision: 5957

Modified:
   jifty/trunk/lib/Jifty/Action/Record.pm
   jifty/trunk/lib/Jifty/Action/Record/Create.pm
   jifty/trunk/lib/Jifty/Action/Record/Update.pm

Log:
* add possible_columns method to Jifty/Action/Record*
* Usually at the end names are required, however for subclassing column objects
  are better, or possible_fields method in a subclass turns out to be "map to column" -
  "filter" - "map to name" chain.


Modified: jifty/trunk/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record.pm	(original)
+++ jifty/trunk/lib/Jifty/Action/Record.pm	Tue Oct 21 03:43:38 2008
@@ -505,17 +505,33 @@
     return @choices;
 }
 
+=head2 possible_columns
+
+Returns the list of columns objects on the object that the action
+can update. This defaults to all of the C<containers> or the non-C<private>,
+non-C<virtual> and non-C<serial> columns of the object.
+
+=cut
+
+sub possible_columns {
+    my $self = shift;
+    return grep { $_->container or (!$_->private and !$_->virtual and $_->type ne "serial") } $self->record->columns;
+}
+
 
 =head2 possible_fields
 
-Returns the list of fields on the object that the action can update.
-This defaults to all of the non-C<private> fields of the object.
+Returns the list of the L</possible_columns>' names.
+
+Usually at the end names are required, however for subclassing column objects
+are better, or this method in a subclass turns out to be "map to column" -
+"filter" - "map to name" chain.
 
 =cut
 
 sub possible_fields {
     my $self = shift;
-    return map { $_->name } grep { $_->container or (!$_->private and !$_->virtual and $_->type ne "serial") } $self->record->columns;
+    return map { $_->name } $self->possible_columns;
 }
 
 =head2 take_action

Modified: jifty/trunk/lib/Jifty/Action/Record/Create.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record/Create.pm	(original)
+++ jifty/trunk/lib/Jifty/Action/Record/Create.pm	Tue Oct 21 03:43:38 2008
@@ -131,17 +131,16 @@
     $self->result->message(_("Created"))
 }
 
-=head2 possible_fields
+=head2 possible_columns
 
 Create actions do not provide fields for columns marked as C<private>
 or C<protected>.
 
 =cut
 
-sub possible_fields {
+sub possible_columns {
     my $self = shift;
-    my @names = $self->SUPER::possible_fields;
-    return map {$_->name} grep {not $_->protected} map {$self->record->column($_)} @names;
+    return grep {not $_->protected} $self->SUPER::possible_columns( @_ );
 }
 
 =head1 SEE ALSO

Modified: jifty/trunk/lib/Jifty/Action/Record/Update.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record/Update.pm	(original)
+++ jifty/trunk/lib/Jifty/Action/Record/Update.pm	Tue Oct 21 03:43:38 2008
@@ -223,17 +223,16 @@
 }
 
 
-=head2 possible_fields
+=head2 possible_columns
 
 Update actions do not provide fields for columns marked as C<private>
 or C<protected>.
 
 =cut
 
-sub possible_fields {
+sub possible_columns {
     my $self = shift;
-    my @names = $self->SUPER::possible_fields;
-    return map {$_->name} grep {not $_->protected} map {$self->record->column($_)} @names;
+    return grep { not $_->protected } $self->SUPER::possible_columns;
 }
 
 =head1 SEE ALSO


More information about the Jifty-commit mailing list