From: Matt S Trout Date: Wed, 20 Jan 2010 11:04:08 +0000 (+0000) Subject: add a couple bits and pieces X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7cd0d8a945852181bc4a87bb767743ef6358437c;p=dbsrgits%2FDBIx-Data-Store-old.git add a couple bits and pieces --- diff --git a/lib/DBIx/Data/Collection/Set.pm b/lib/DBIx/Data/Collection/Set.pm index a6188f4..3e965ba 100644 --- a/lib/DBIx/Data/Collection/Set.pm +++ b/lib/DBIx/Data/Collection/Set.pm @@ -3,6 +3,7 @@ package DBIx::Data::Collection::Set; use Moose; use Method::Signatures::Simple; use Data::Perl::Stream::Array; +use Data::Perl::Collection::Set; use Scalar::Util qw(weaken refaddr); has _store => (is => 'ro', required => 1, init_arg => 'store'); @@ -212,6 +213,20 @@ method as_stream { Data::Perl::Stream::Array->new(array => $self->_member_cache); } +# theoretically inefficient except that if we're being asked this then +# either the data should have been pre-loaded or we're going to get all +# elements anyway + +method count { + scalar $self->flatten +} + +method map ($sub) { + Data::Perl::Collection::Set->new( + members => [ map $sub->($_), $self->flatten ] + ) +} + method _set_caches ($members) { $self->_set_member_cache($members); $self->_set_key_cache_members($members); diff --git a/lib/DBIx/Data/Store/CRUD.pm b/lib/DBIx/Data/Store/CRUD.pm index c81dd0b..836f872 100644 --- a/lib/DBIx/Data/Store/CRUD.pm +++ b/lib/DBIx/Data/Store/CRUD.pm @@ -14,6 +14,8 @@ has 'insert_command_constructor' => (is => 'ro'); has "select_column_order" => (is => 'ro'); +has implicit_arguments => (is => 'ro'); + method new_select_command ($args) { die "$self->has_select_sql" unless $self->has_select_sql; $self->raw_store->new_stream_command( @@ -33,6 +35,9 @@ method new_select_single_command ($args) { } method _unwrap_args_for ($type, $args) { + if (my $implicit = $self->implicit_arguments) { + $args = { %$implicit, %$args }; + } [ @{$args}{@{$self->${\"${type}_argument_order"}}} ] }