package Dancer2::Plugin::Menu ; use 5.010; use strict; use warnings; use Dancer2::Plugin; sub BUILD { my $plugin = shift; $plugin->_do_stuff } sub _do_stuff { my $plugin = shift; print Dumper $plugin; # does not print anything, undefined ... return $array_ref; } #### use Test::Most tests => 1, 'die'; BEGIN { $ENV{'DANCER_ENVIRONMENT'} = 'testing'; } package TestApp; use Dancer2; use Dancer2::Plugin::Menu; use Data::Dumper qw 'Dumper'; get '/' => sub { return 'hello' }; get '/test' => sub { return 'hi' }; # do_stuff method gets called, but no object is passed to it so function won't work properly deep_cmp [ '/', '/test' ], Dancer2::Plugin::Menu::do_stuff, 'returns expected array';