[Bps-public-commit] r12442 - in Prophet/trunk: .
jesse at bestpractical.com
jesse at bestpractical.com
Sat May 17 05:31:22 EDT 2008
Author: jesse
Date: Sat May 17 05:31:21 2008
New Revision: 12442
Modified:
Prophet/trunk/ (props changed)
Prophet/trunk/lib/Prophet/Record.pm
Log:
r31107 at dhcp113 (orig r12376): sartak | 2008-05-16 19:50:42 +0900
r55966 at onn: sartak | 2008-05-16 06:04:23 -0400
Allow loading records by luid
Modified: Prophet/trunk/lib/Prophet/Record.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Record.pm (original)
+++ Prophet/trunk/lib/Prophet/Record.pm Sat May 17 05:31:21 2008
@@ -140,9 +140,30 @@
sub load {
my $self = shift;
- my %args = validate( @_, { uuid => 1 } );
- $self->uuid( $args{uuid} );
- $self->find_or_create_luid();
+
+ my %args = validate(@_, {
+ uuid => {
+ optional => 1,
+ callbacks => {
+ 'uuid or luid present' => sub { $_[0] || $_[1]->{luid} },
+ },
+ },
+ luid => {
+ optional => 1,
+ callbacks => {
+ 'luid or uuid present' => sub { $_[0] || $_[1]->{uuid} },
+ },
+ },
+ });
+
+ if ($args{luid}) {
+ $self->luid( $args{luid} );
+ $self->uuid( $self->handle->find_uuid_by_luid(luid => $args{luid}) );
+ }
+ else {
+ $self->uuid( $args{uuid} );
+ $self->find_or_create_luid();
+ }
return $self->handle->record_exists( uuid => $self->uuid, type => $self->type );
}
More information about the Bps-public-commit
mailing list