1Ordered(3)            User Contributed Perl Documentation           Ordered(3)
2
3
4

NAME

6       Module::Pluggable::Ordered - Call module plugins in a specified order
7

SYNOPSIS

9           package Foo;
10           use Module::Pluggable::Ordered;
11
12           Foo->call_plugins("some_event", @stuff);
13
14               for my $plugin (Foo->plugins()){
15                       $plugin->method();
16               }
17
18       Meanwhile, in a nearby module...
19
20           package Foo::Plugin::One;
21           sub some_event_order { 99 } # I get called last of all
22           sub some_event { my ($self, @stuff) = @_; warn "Hello!" }
23
24               sub _order { 99 } # I get listed by plugins_ordered() last
25
26       And in another:
27
28           package Foo::Plugin::Two;
29           sub some_event_order { 13 } # I get called relatively early
30           sub some_event { ... }
31
32               sub _order { 10 } # I get listed by plugins_ordered() early
33

DESCRIPTION

35       This module behaves exactly the same as "Module::Pluggable", supporting
36       all of its options, but also mixes in the "call_plugins" and
37       "plugins_ordered" methods to your class. "call_plugins" acts a little
38       like "Class::Trigger"; it takes the name of a method, and some
39       parameters. Let's say we call it like so:
40
41           __PACKAGE__->call_plugins("my_method", @something);
42
43       "call_plugins" looks at the plugin modules found using
44       "Module::Pluggable" for ones which provide "my_method_order". It sorts
45       the modules numerically based on the result of this method, and then
46       calls "$_->my_method(@something)" on them in order. This produces an
47       effect a little like the System V init process, where files can specify
48       where in the init sequence they want to be called.
49
50       "plugins_ordered" extends the "plugins" method created by
51       "Module::Pluggable" to list the plugins in defined order. It looks for
52       a "_order" method in the modules found using "Module::Pluggable", and
53       returns the modules sorted numerically in that order. For example:
54
55               my @plugins = __PACKAGE__->plugins();
56
57       The resulting array of plugins will be sorted. If no "_order"
58       subroutine is defined for a module, an arbitrary default value of 50 is
59       used.
60

OPTIONS

62       The "package" option can be used to put the pluggability into another
63       package, to be used for modules building on the functionality of this
64       one.
65
66       It also provides the "only" and "except" options.
67
68            # will only return the Foo::Plugin::Quux plugin
69            use Module::Pluggable::Ordered only => [ "Foo::Plugin::Quux" ];
70
71            # will not return the Foo::Plugin::Quux plugin
72            use Module::Pluggable::Ordered except => [ "Foo::Plugin::Quux" ];
73

SEE ALSO

75       Module::Pluggable, Class::Trigger
76

AUTHOR

78       Simon Cozens, <simon@cpan.org> (author emeritus)
79
80       Christopher Nehren, <apeiron@cpan.org> (current maintainer)
81
82       Please report bugs via the CPAN RT tracker at http://rt.cpan.org.
83
85       Copyright 2004 by Simon Cozens
86
87       Copyright 2004 by Christopher Nehren (current copyright holder)
88
89       This library is free software; you can redistribute it and/or modify it
90       under the same terms as Perl itself.
91

ACKNOWLEDGEMENTS

93       Thank you to Simon Cozens for originally writing this module.
94
95       Thanks to Lars Thegler for indirectly alerting me to the fact that my
96       POD was horribly broken, for providing patches to make this module work
97       with Perl versions < 5.6, for maintaining the port up to version 1.3,
98       and for allowing me to take maintainership for versions 1.3 onwards.
99
100
101
102perl v5.34.0                      2022-01-21                        Ordered(3)
Impressum