Create new configuration object.
+ my $config = new WebPAC::Config(
+ path => '/optional/path/to/config.yml'
+ );
+
=cut
sub new {
=head2 databases
+Return all databases in config
+
my $config_databases_hash = $config->databases;
my @config_databases_names = $config->databases;
=head2 use_indexer
+Which indexer are we using?
+
$config->use_indexer;
=cut
}
+=head2 iterate_inputs
+
+ $config->iterate_inputs( sub {
+ my $input = shift;
+ # ... do something with input config hash
+ } );
+
+=cut
+
+sub iterate_inputs {
+ my $self = shift;
+
+ my $log = $self->_get_logger();
+
+ my $code_ref = shift;
+ $log->logdie("called with CODE") unless ( ref($code_ref) eq 'CODE' );
+
+ while (my ($database, $db_config) = each %{ $self->{config}->{databases} }) {
+ my @inputs;
+ if (ref($db_config->{input}) eq 'ARRAY') {
+ @inputs = @{ $db_config->{input} };
+ } elsif ($db_config->{input}) {
+ push @inputs, $db_config->{input};
+ } else {
+ $log->info("database $database doesn't have inputs defined");
+ }
+
+ foreach my $input (@inputs) {
+ $log->debug("iterating over input ", dump($input));
+ $code_ref->($input);
+ }
+ }
+
+}
+
+
=head1 AUTHOR
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
diag "inputs = ",dump( @inputs ) if ($debug);
isa_ok(\@inputs, 'ARRAY', "inputs");
cmp_ok(@inputs, '==', 2, "got 2 webpac inputs");
+
+$config->iterate_inputs(sub {
+ my $input = shift;
+ diag "input = ",dump($input);
+});