File: OnPluginImport.pm

package info (click to toggle)
libdancer2-perl 0.400001%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,580 kB
  • sloc: perl: 8,461; makefile: 9
file content (26 lines) | stat: -rw-r--r-- 571 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Dancer2::Plugin::OnPluginImport;
use Dancer2::Plugin;

# register keyword
register some_import => sub { shift->dancer_version };

# register hook
register_hook qw(imported_plugin);

# add hook. This triggers the $dsl->hooks attribute
# to be built plugins added after this should still
# be able to register and add hooks. See #889.
on_plugin_import {
    my $dsl = shift;

    $dsl->app->add_hook(
        Dancer2::Core::Hook->new(
            name => 'imported_plugin',
            code => sub { $dsl->dancer_version }
        )
    );
};

register_plugin;

1;