[Bps-public-commit] r12462 - in Prophet/branches/moose: . lib/Prophet/Resolver lib/Prophet/Test t
sartak at bestpractical.com
sartak at bestpractical.com
Sat May 17 06:13:52 EDT 2008
Author: sartak
Date: Sat May 17 06:13:51 2008
New Revision: 12462
Modified:
Prophet/branches/moose/ (props changed)
Prophet/branches/moose/lib/Prophet/CLI.pm
Prophet/branches/moose/lib/Prophet/Resolver/FromResolutionDB.pm
Prophet/branches/moose/lib/Prophet/Test.pm
Prophet/branches/moose/lib/Prophet/Test/Participant.pm
Prophet/branches/moose/t/create.t
Prophet/branches/moose/t/generalized_sync_n_merge.t
Log:
r56191 at onn: sartak | 2008-05-17 06:13:34 -0400
Make use of Collection->items being a smarter attribute
Modified: Prophet/branches/moose/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/CLI.pm (original)
+++ Prophet/branches/moose/lib/Prophet/CLI.pm Sat May 17 06:13:51 2008
@@ -351,7 +351,7 @@
my $search_cb = $self->get_search_callback();
$records->matching($search_cb);
- for ( sort { $a->uuid cmp $b->uuid } @{ $records->as_array_ref } ) {
+ for ( sort { $a->uuid cmp $b->uuid } $records->items ) {
if ( $_->summary_props ) {
print $_->format_summary . "\n";
} else {
Modified: Prophet/branches/moose/lib/Prophet/Resolver/FromResolutionDB.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Resolver/FromResolutionDB.pm (original)
+++ Prophet/branches/moose/lib/Prophet/Resolver/FromResolutionDB.pm Sat May 17 06:13:51 2008
@@ -19,14 +19,12 @@
type => '_prophet_resolution-' . $conflicting_change->fingerprint
);
$res->matching( sub {1} );
- return unless @{ $res->as_array_ref };
-
- # return unless scalar @{ $res->as_array_ref };
+ return unless $res->count;
my %answer_map;
my %answer_count;
- for my $answer ( @{ $res->as_array_ref } ) {
+ for my $answer ($res->items) {
my $key = sha1_hex( to_json($answer->get_props, {utf8 => 1, pretty => 1, canonical => 1}));
$answer_map{$key} ||= $answer;
$answer_count{$key}++;
Modified: Prophet/branches/moose/lib/Prophet/Test.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Test.pm (original)
+++ Prophet/branches/moose/lib/Prophet/Test.pm Sat May 17 06:13:51 2008
@@ -242,7 +242,7 @@
my $cli = Prophet::CLI->new();
my $tickets = Prophet::Collection->new( handle => $cli->app_handle->handle, type => $Prophet::Replica::MERGETICKET_METATYPE );
$tickets->matching( sub {1} );
- return { map { $_->uuid => $_->prop('last-changeset') } @{ $tickets->as_array_ref } };
+ return { map { $_->uuid => $_->prop('last-changeset') } $tickets->items };
}
Modified: Prophet/branches/moose/lib/Prophet/Test/Participant.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Test/Participant.pm (original)
+++ Prophet/branches/moose/lib/Prophet/Test/Participant.pm Sat May 17 06:13:51 2008
@@ -148,9 +148,9 @@
$resolutions->matching( sub {1} );
$merges->matching( sub {1} );
- %{ $state->{records} } = map { $_->uuid => $_->get_props } @{ $records->as_array_ref };
- %{ $state->{merges} } = map { $_->uuid => $_->get_props } @{ $merges->as_array_ref };
- %{ $state->{resolutions} } = map { $_->uuid => $_->get_props } @{ $resolutions->as_array_ref };
+ %{ $state->{records} } = map { $_->uuid => $_->get_props } $records->items;
+ %{ $state->{merges} } = map { $_->uuid => $_->get_props } $merges->items;
+ %{ $state->{resolutions} } = map { $_->uuid => $_->get_props } $resolutions->items;
return $state;
Modified: Prophet/branches/moose/t/create.t
==============================================================================
--- Prophet/branches/moose/t/create.t (original)
+++ Prophet/branches/moose/t/create.t Sat May 17 06:13:51 2008
@@ -29,18 +29,16 @@
my $people = Prophet::Collection->new( handle => $cxn, type => 'Person' );
$people->matching( sub { ( shift->prop('species') || '' ) ne 'cat' } );
-is( $#{ $people->as_array_ref }, 1 );
-my @people = @$people;
-is_deeply( [ sort map { $_->prop('name') } @people ], [qw(Jesse Kaia)] );
+is( $people->count, 2 );
+is_deeply( [ sort map { $_->prop('name') } @$people ], [qw(Jesse Kaia)] );
my $cats = Prophet::Collection->new( handle => $cxn, type => 'Person' );
$cats->matching( sub { ( shift->prop('species') || '' ) eq 'cat' } );
-is( $#{ $cats->as_array_ref }, 1 );
-my @cats = @{ $cats->as_array_ref };
-for (@cats) {
+is( $cats->count , 2 );
+for (@$cats) {
is( $_->prop('age'), "0.7" );
}
-is_deeply( [ sort map { $_->prop('name') } @cats ], [qw(Mao Mei)] );
+is_deeply( [ sort map { $_->prop('name') } @$cats ], [qw(Mao Mei)] );
my $cat = Prophet::Record->new( handle => $cxn, type => 'Person' );
$cat->load( uuid => $mao );
@@ -49,16 +47,16 @@
$cat2->load( uuid => $mei );
$cat2->set_prop( name => 'age', value => '0.8' );
-is( $#{ $cats->as_array_ref }, 1 );
-for (@cats) {
+is( $cats->count, 2 );
+for (@$cats) {
is( $_->prop('age'), "0.8" );
}
-for (@cats) {
+for (@$cats) {
ok( $_->delete );
}
my $records = Prophet::Collection->new( type => 'Person', handle => $cxn );
$records->matching( sub {1} );
-is( $#{ $records->as_array_ref }, 1 );
+is( $records->count, 2 );
1;
Modified: Prophet/branches/moose/t/generalized_sync_n_merge.t
==============================================================================
--- Prophet/branches/moose/t/generalized_sync_n_merge.t (original)
+++ Prophet/branches/moose/t/generalized_sync_n_merge.t Sat May 17 06:13:51 2008
@@ -61,7 +61,7 @@
);
$records->matching( sub {1} );
use Data::Dumper;
- for ( @{ $records->as_array_ref } ) {
+ for ($records->items) {
warn $_->uuid . ' : ' . Dumper( $_->get_props );
}
}
More information about the Bps-public-commit
mailing list