From a30d19b19fcd5ee63ae2ea446f4bd23578f34093 Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Mon, 24 Apr 2017 20:30:02 -0400 Subject: [PATCH] somewhat working, placeholders arent working? --- lib/App.pm | 8 ++++++++ lib/App/Model/Eval.pm | 4 +++- lib/App/Model/Paste.pm | 2 +- lib/App/Model/Perlbot.pm | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/App.pm b/lib/App.pm index 8a92fd1..b413baf 100644 --- a/lib/App.pm +++ b/lib/App.pm @@ -11,6 +11,10 @@ use App::Config; use App::Controller::Paste; use App::Controller::Eval; use App::Controller::Apiv1; +use App::Model::Paste; +use App::Model::Eval; +use App::Model::Perlbot; + sub startup { my $self = shift; @@ -29,6 +33,10 @@ sub startup { $self->plugin('BlogSpam' => ($cfg->{blogspam}->%*)); } + $self->helper(paste => sub {state $paste = App::Model::Paste->new}); + $self->helper(eval => sub {state $eval = App::Model::Eval->new}); + $self->helper(perlbot => sub {state $perlbot = App::Model::Perlbot->new}); + $self->setup_routes(); } diff --git a/lib/App/Model/Eval.pm b/lib/App/Model/Eval.pm index f1d3561..c28984b 100644 --- a/lib/App/Model/Eval.pm +++ b/lib/App/Model/Eval.pm @@ -12,7 +12,7 @@ use POE::Filter::Reference; use App::Config; use App::Memcached; -has cfg => App::Config::get_config('evalserver'); +has cfg => sub {App::Config::get_config('evalserver')}; sub get_eval { my ($self, $paste_id, $code, $lang) = @_; @@ -37,3 +37,5 @@ sub get_eval { return $str; } } + +1; diff --git a/lib/App/Model/Paste.pm b/lib/App/Model/Paste.pm index 0475806..fcc0da3 100644 --- a/lib/App/Model/Paste.pm +++ b/lib/App/Model/Paste.pm @@ -7,7 +7,7 @@ use DBI; use Mojo::Base '-base'; # TODO config for dbname -has 'dbh' = DBI->connect("dbi:SQLite:dbname=pastes.db", "", "", {RaiseError => 1, sqlite_unicode => 1}); +has 'dbh' => sub {DBI->connect("dbi:SQLite:dbname=pastes.db", "", "", {RaiseError => 1, sqlite_unicode => 1})}; sub insert_pastebin { my $self = shift; diff --git a/lib/App/Model/Perlbot.pm b/lib/App/Model/Perlbot.pm index f438dd1..66ea449 100644 --- a/lib/App/Model/Perlbot.pm +++ b/lib/App/Model/Perlbot.pm @@ -7,7 +7,7 @@ use Data::Dumper; use Mojo::Base '-base'; -has config => App::Config::get_config('announce'); +has config => sub {App::Config::get_config('announce')}; sub announce { my $self = shift;