From: John Napiorkowski Date: Wed, 9 Feb 2011 23:00:37 +0000 (-0500) Subject: add an option to exclude some sources from the all option X-Git-Tag: 1.001011~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=47a8ceb927de1d34efb41834e89dd6020a0d3191;p=dbsrgits%2FDBIx-Class-Fixtures.git add an option to exclude some sources from the all option --- diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index 0f0b6de..4f995b9 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -484,6 +484,10 @@ sub dump { } } + if($params->{excludes} && !$params->{all}) { + return DBIx::Class::Exception->throw("'excludes' param only works when using the 'all' param"); + } + my $schema = $params->{schema}; my $config; if ($params->{config}) { @@ -491,11 +495,17 @@ sub dump { my $config_file = $self->config_dir->file($params->{config}); $config = $self->load_config_file($config_file); } elsif ($params->{all}) { + my %excludes = map {$_=>1} @{$params->{excludes}||[]}; $config = { might_have => { fetch => 0 }, has_many => { fetch => 0 }, belongs_to => { fetch => 0 }, - sets => [map {{ class => $_, quantity => 'all' }} $schema->sources] + sets => [ + map { + { class => $_, quantity => 'all' }; + } grep { + !$excludes{$_} + } $schema->sources], }; } else { DBIx::Class::Exception->throw('must pass config or set all');