I tend to use the excellent Import::Base from Doug Bell when I need to bring 
groups of my commonly used modules into an application. Check it out - I think 
you’ll find it useful!

Jason A. Crome / CromeDome
CPAN: https://metacpan.org/author/CROMEDOME
github: https://github.com/cromedome
Twitter: https://twitter.com/cromedome



> On Dec 15, 2017, at 11:10 AM, Steve Dondley <sdond...@gmail.com> wrote:
> 
> Here's the few lines from a hypothetical MainApp in /lib:
> 
> # File 1
> package MainApp;
> use ExtendingApp;
> use HTML::Element;
> 
> And here is a perl module that extends this app.
> 
> # File 2
> package ExtendingApp;
> use Dancer2 appname => MainApp;
> 
> get '/' => sub {
>    my $element = HTML::Element->new('h1');
> };
> 
> ### END ###
> 
> This works. I get no errors because the HTML::Element module can be seen 
> inside routes. However, unless I'm missing something, this doesn't work.
> 
> # File 1
> package MainApp;
> use ExtendingApp;
> use Dancer2::Plugin::Database;
> 
> # File 2
> package ExtendingApp;
> use Dancer2 appname => MainApp;
> 
> get '/' => sub {
>    my @data = database->quick_select('test_table', {});
> };
> 
> ### END ###
> 
> The above results in an error: Can't locate object method "quick_select" via 
> package "database" (perhaps you forgot to load "database"?)
> 
> I'm forced to add "use Dancer2::Plugin::Database" to File 2. I'm curious to 
> know if there's some way to import commonly used plugins into extension apps.
> 
> Thanks!
> 
> 
> 
> 
> _______________________________________________
> dancer-users mailing list
> dancer-users@dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

_______________________________________________
dancer-users mailing list
dancer-users@dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to