++ed by:
1 non-PAUSE user
Author image Михаил Че
  my $dbh = {};
  
  my $req_dbi;
  while (my ($db, $opt) = each %$c_dbh) {
    if ($opt->{dbh}) {# && ref $opt eq 'DBI::db'
      $dbh->{$db} ||= $opt->{dbh};
    } else {
      ++$req_dbi
        and require DBI
        unless $req_dbi;
      $dbh->{$db} ||= DBI->connect(@{$opt->{connect}});
      $app->log->debug("Соединил�� � базой $opt->{connect}[0] app->dbh->{'$db'}");
    }
    
    map {
      $dbh->{$db}->do($_);
    } @{$opt->{do}} if $opt->{do};
    

  }
  return $dbh;
  

};

Mojolicious::Che

Доброго в�ем

¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !

VERSION

0.0919

NAME

Mojolicious::Che - Мой базовый модуль дл� приложений Mojolicious. �ужен только развернутый конфиг.

SYNOPSIS

  # app.pl
  use lib 'lib';
  use Mojo::Base 'Mojolicious::Che';
  __PACKAGE__->new(config => 'lib/Config.pm')->start();

Config file

Пор�док �трок в �том конфиге �оответ�твует и�полнению в модуле!

  {
  'Проект'=>'Те�т-проект',
  # mojo => {
    # defaults =>
    # secrets =>
    # mode=>
    # log => {level=>...}
    # static => {paths => [...]},
    # renderer => {paths => [...], classes => [...], },
    # session[s] =>
    # has =>
    # plugins =>
    # hooks =>
    # namespaces =>
    # routes =>
    # jobs =>
    # types =>
  # },
  # or with prefix mojo_
  # Default values for "stash" in Mojolicious::Controller, assigned for every new request.
  mojo_defaults => {layout=>'default',},
  # 'шифры' => [
  mojo_secrets => ['true 123 my app',],
  mojo_mode=> 'development',
  mojo_log=>{level => 'error'},
  mojo_static_paths => ["static"],
  mojo_renderer_classes => ["Mojolicious::Foo::Fun"],
  # '�е��и�'(или �е��ии) => 
  mojo_session[s] => {cookie_name => 'EXX', default_expiration => 86400},
  
  # 'хазы' => 'Лет 500-700 назад был такой дикий �тепной торговый жадный народ Х�З�РЫ. Столицей их "го�удар�тва" был город Тьмутаракань, где-то на берегу мор� Ка�пи�. Потомки �тих людей ра��ыпаны по �транам Ро��ии, Средней �зии, Европы. Е�ть мнение, что хазары при�воили �ебе название ЕВРЕИ, но �то не те библей�кие кроткие евреи, а жадные потомки кроманьонцев'
  mojo_has => {
    foo => sub {my $app = shift; return 'is a bar';},
  },
  
  # 'плугины'=> [
  mojo_plugins=>[ 
      ['Foo::Bar'],
      [Foo::Bar::Plugin => opt1 => ..., opt2 => ...],
      ['Foo::Plugin' => sub {<...returns config data list...>}],
  ],
  # 'хуки' => 
  mojo_hooks=>{
    #~ before_dispatch => sub {1;},
  },
  # '�пей�ы' => [...]
  namespaces => ['Space::Shattle'],
  # 'маршруты' => [...]
  routes => [
    [get=>'/', to=> {cb=>sub{shift->render(format=>'txt', text=>'Hello friend!');},}],
  ]
  #~ 'задачи'=> {#first enable plugin Minion
  jobs => {
    slow_log => sub {
      my ($job, $msg) = @_;
      sleep 5;
      $job->app->log->error(qq{slow_log "$msg"});
    },
  },
  # или 'типы'=>{...}
  types => {
    docx => ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
    ...
  },
  };

ATTRIBUTES

Mojolicious::Che inherits all attributes from Mojolicious and implements the following new ones.

dbh

Set DBI handlers from config dbh (или базы)

  my $dbh = $app->dbh->{main};

sth

Set prepared stattements from config sth (или запро�ы).

  my $sth = $app->sth->{main}{foo};

плугины

Apply the plugins. See Mojolicious#plugins, Mojolicious::Plugins.

METHODS

Mojolicious::Che inherits all methods from Mojolicious and implements the following new ones.

�е��и�()

Session object config apply. See Mojolicious#sessions, Mojolicious::Sessions.

хазы()

Apply the has's. UTF names allow.

хуки()

Apply the hooks. See Mojolicious#HOOKS.

�пей�ы()

Apply the namespaces. Push @{$app->routes->namespaces} your namespaces. See Mojolicious#routes.

  namespaces => ['Space::Shattle'],

маршруты()

Apply the routes. See Mojolicious#routes, Mojolicious::Guides::Routing.

  #~ 'маршруты' => [
  'routes'=>[
    [get=>'/', to=> {cb=>sub{shift->render(format=>'txt', text=>'Welcome!');},}],
  ],

задачи()

Apply the jobs. See Minion.

  #~ 'задачи'=> {#first enable plugin Minion
  'jobs'=> { # or tasks
    slow_log => sub {
      my ($job, $msg) = @_;
      sleep 5;
      $job->app->log->error(qq{slow_log "$msg"});
    },
    
  },

Apply the new types. See Mojolicious#types, Mojolicious::Types.

SEE ALSO

Mojolicious

Ado

AUTHOR

Михаил Че (Mikhail Che), <mche[-at-]cpan.org>

BUGS / CONTRIBUTING

Please report any bugs or feature requests at https://github.com/mche/Mojolicious-Che/issues. Pull requests also welcome.

COPYRIGHT

Copyright 2016+ Mikhail Che.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

4 POD Errors

The following errors were encountered while parsing the POD:

Around line 90:

=pod directives shouldn't be over one line long! Ignoring all 6 lines of content

Around line 91:

Non-ASCII character seen before =encoding in 'базы'. Assuming CP1252

Around line 261:

Couldn't do =encoding utf8: Encoding is already set to CP1252

Around line 421:

Unknown directive: =head