| 1 | package Acme::Crux::Plugin; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | use utf8; | ||
| 5 | |||
| 6 | =encoding utf-8 | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Acme::Crux::Plugin - The Acme::Crux plugin base class | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | package Acme::Crux::Plugin::MyPlugin; | ||
| 15 | use parent 'Acme::Crux::Plugin'; | ||
| 16 | sub register { | ||
| 17 | my ($self, $app, $args) = @_; | ||
| 18 | # ... your code here ... | ||
| 19 | } | ||
| 20 | |||
| 21 | # In your appliction: | ||
| 22 | $app->plugin( myplugin => 'Acme::Crux::Plugin::MyPlugin' ); | ||
| 23 | |||
| 24 | =head1 DESCRIPTION | ||
| 25 | |||
| 26 | The Acme::Crux plugin abstract base class | ||
| 27 | |||
| 28 | =head2 new | ||
| 29 | |||
| 30 | my $plugin = Acme::Crux::Plugin->new( 'myplugin' ); | ||
| 31 | |||
| 32 | =head1 METHODS | ||
| 33 | |||
| 34 | This class implements the following methods | ||
| 35 | |||
| 36 | =head2 name | ||
| 37 | |||
| 38 | my $name = $plugin->name; | ||
| 39 | |||
| 40 | Tgis method returns name of this plugin | ||
| 41 | |||
| 42 | =head2 register | ||
| 43 | |||
| 44 | $plugin->register( $app, $plugin_args ); | ||
| 45 | $plugin->register( $app, @$plugin_args ); | ||
| 46 | |||
| 47 | This method will be called at startup time. You should overload it in your subclass | ||
| 48 | |||
| 49 | =head1 TO DO | ||
| 50 | |||
| 51 | See C<TODO> file | ||
| 52 | |||
| 53 | =head1 SEE ALSO | ||
| 54 | |||
| 55 | L<CTK::Plugin>, L<Mojolicious::Plugin> | ||
| 56 | |||
| 57 | =head1 AUTHOR | ||
| 58 | |||
| 59 | Serż Minus (Sergey Lepenkov) L<https://www.serzik.com> E<lt>abalama@cpan.orgE<gt> | ||
| 60 | |||
| 61 | =head1 COPYRIGHT | ||
| 62 | |||
| 63 | Copyright (C) 1998-2026 D&D Corporation | ||
| 64 | |||
| 65 | =head1 LICENSE | ||
| 66 | |||
| 67 | This program is distributed under the terms of the Artistic License Version 2.0 | ||
| 68 | |||
| 69 | See the C<LICENSE> file or L<https://opensource.org/license/artistic-2-0> for details | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | use Carp qw/croak/; | ||
| 74 | |||
| 75 | sub new { bless { name => $_[1] }, $_[0] } | ||
| 76 | sub name { shift->{name} } | ||
| 77 | sub register { croak 'Method "register" not implemented by subclass' } | ||
| 78 | |||
| 79 | 1; | ||
| 80 | |||
| 81 | __END__ |