[snip]

You're better off moving all that code into a separate module, something like this:

package My::Work::Module;
use Mojo::Base '-base';

has 'app' => undef;
has 'log' => sub {
  my $self = shift;
  return $self->app->log if defined $self->app;
  return Mojo::Log->new(\%your_log_options);
};
has 'dbh' => undef;

sub ImportClients {
...
}

1;

In your app code you can then use that as such:

my $work = My::Work::Module->new(app => $self->app, dbh => GetMyDBHandle());

And in command line scripts, you'd set up the DBH, and would just do:
my $work = My::Work::Module->new(dbh => $my_dbh);

And it would then not have an app attribute, but i would have a log attribute. You'd just have to make sure that code in the work module calls "$self->log->debug(...)" and not "$self->app->log->debug".

At least that's how I'd do it....

--
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to