Last active
January 31, 2019 01:13
-
-
Save preaction/2ef3b9c321e6d27c093733082b840d7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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