--- lib/A3C/LDAP.pm 2008/03/30 22:29:42 45 +++ lib/A3C/LDAP.pm 2008/03/31 21:11:45 47 @@ -104,7 +104,12 @@ =head2 as_collection_of - my $connection = $ldap->collection('Organization', $limit); + my $connection = $ldap->collection( + # name of model to use + 'Organization', + # optional params + limit => $limit, + ); =cut @@ -114,9 +119,11 @@ }; sub collection { - my ( $self, $model, $limit ) = @_; + my $self = shift; + my $model = shift or die "no model?"; + my $args = {@_}; - $limit ||= 0; # unlimited by default + $args->{limit} ||= 0; # unlimited by default my $filter = $collection2filter->{$model}; die "unknown model $model" unless $filter; @@ -124,10 +131,14 @@ $self->search( base => $self->base, filter => $filter, - sizelimit => $limit, + sizelimit => $args->{limit}, ); - Jifty->log->info("searching LDAP for $model with $filter limit $limit returned ", $self->count, " results"); + Jifty->log->info( + "searching LDAP for $model with $filter ", + $args->{limit} ? 'limit ' . $args->{limit} : '', + 'returned ', $self->count, ' results' + ); my $class = Jifty->app_class('Model', $model . 'Collection' ) or die "can't create ${model}Collection"; my $collection = $class->new() or die "can't $class->new";