[Bps-public-commit] r10297 - in Net-Hiveminder: lib/Net
sartak at bestpractical.com
sartak at bestpractical.com
Sat Jan 12 22:46:27 EST 2008
Author: sartak
Date: Sat Jan 12 22:46:26 2008
New Revision: 10297
Modified:
Net-Hiveminder/ (props changed)
Net-Hiveminder/lib/Net/Hiveminder.pm
Log:
r50235 at onn: sartak | 2008-01-12 22:45:52 -0500
Add a tasks2ids method for downgrading record locators
Modified: Net-Hiveminder/lib/Net/Hiveminder.pm
==============================================================================
--- Net-Hiveminder/lib/Net/Hiveminder.pm (original)
+++ Net-Hiveminder/lib/Net/Hiveminder.pm Sat Jan 12 22:46:26 2008
@@ -189,7 +189,7 @@
sub read_task {
my $self = shift;
my $loc = shift;
- my $id = $LOCATOR->decode($loc);
+ my $id = $self->tasks2ids($loc);
return $self->read(Task => id => $id);
}
@@ -203,7 +203,7 @@
sub update_task {
my $self = shift;
my $loc = shift;
- my $id = $LOCATOR->decode($loc);
+ my $id = $self->tasks2ids($loc);
return $self->update(Task => id => $id, @_);
}
@@ -217,7 +217,7 @@
sub delete_task {
my $self = shift;
my $loc = shift;
- my $id = $LOCATOR->decode($loc);
+ my $id = $self->tasks2ids($loc);
return $self->delete(Task => id => $id);
}
@@ -335,11 +335,29 @@
my $self = shift;
for (@_) {
- my $id = $LOCATOR->decode($_);
+ my $id = $self->tasks2ids($_);
$self->update('Task', id => $id, complete => 1);
}
}
+=head2 tasks2ids LOCATORS -> IDS
+
+Transforms the given record locators (or tasks) to regular IDs.
+
+=cut
+
+sub tasks2ids {
+ my $self = shift;
+
+ my @ids = map {
+ my $locator = $_;
+ $locator =~ s/^#+//; # remove leading #
+ $LOCATOR->decode($locator);
+ } @_;
+
+ return wantarray ? @ids : $ids[0];
+}
+
=head1 SEE ALSO
L<Jifty>, L<Net::Jifty>
More information about the Bps-public-commit
mailing list