Skip to content

Instantly share code, notes, and snippets.

@preaction
Last active January 31, 2019 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save preaction/2ef3b9c321e6d27c093733082b840d7d to your computer and use it in GitHub Desktop.
Save preaction/2ef3b9c321e6d27c093733082b840d7d to your computer and use it in GitHub Desktop.
package Local::Plugin::MyPlugin;
use Mojo::Base 'Mojolicious::Plugin';
sub cached_thing {
state $cache = 'expensive';
return $cache;
}
sub register {
my ( $self, $app, $conf ) = @_;
$app->helper( myplugin => sub { $self } );
}
package main;
use Mojolicious::Lite;
plugin 'Local::Plugin::MyPlugin';
say app->myplugin->cached_thing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment