X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FOrdered.pm;h=5f17790a9a884a3dfd162080a238f1c0900a416f;hb=0c9f24b4acbb659528315a8510c322f61b72bbc7;hp=6c7446fd02fcb61ef4cdddbf75da006c979fb889;hpb=c59dfc82ec97f74d6bd484e5f600f8335335a2fc;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index 6c7446f..5f17790 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -501,7 +501,7 @@ sub move_to_group { } else { my $bumped_pos_val = $self->_position_value ($to_position); - my @between = ($to_position, $new_group_last_position); + my @between = map { $self->_position_value ($_) } ($to_position, $new_group_last_position); $self->_shift_siblings (1, @between); #shift right $self->set_column( $position_column => $bumped_pos_val ); } @@ -682,27 +682,9 @@ You would want to override the methods below if you use sparse if you are working with preexisting non-normalised position data, or if you need to work with materialized path columns. -=head2 _position - - my $num_pos = $item->_position; - -Returns the B of the current object, with the -first object being at position 1, its sibling at position 2 and so on. -By default simply returns the value of L. - -=cut -sub _position { - my $self = shift; - -# #the right way to do this -# return $self->previous_siblings->count + 1; - - return $self->get_column ($self->position_column); -} - =head2 _position_from_value - my $num_pos = $item->_position_of_value ( $pos_value ) + my $num_pos = $item->_position_from_value ( $pos_value ) Returns the B of an object with a B set to C<$pos_value>. By default simply returns C<$pos_value>. @@ -864,6 +846,19 @@ sub _siblings { ); } +=head2 _position + + my $num_pos = $item->_position; + +Returns the B of the current object, with the +first object being at position 1, its sibling at position 2 and so on. + +=cut +sub _position { + my $self = shift; + return $self->_position_from_value ($self->get_column ($self->position_column) ); +} + =head2 _grouping_clause This method returns one or more name=>value pairs for limiting a search