Skip Menu |

This queue is for tickets about the Module-Pluggable CPAN distribution.

Report information
The Basics
Id: 46640
Status: rejected
Priority: 0/
Queue: Module-Pluggable

People
Owner: Nobody in particular
Requestors: icestar [...] inbox.ru
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 3.9
Fixed in: (no value)



Subject: When we use <instantiate> option, <plugins> method creates new plugins object each time when we call it.
I've found one inconvenient restriction in module. When I use <instantiate> option, each call of method <plugins> creates new instances of my plugins. This is not what I expect, I want to get the same plugin objects in different points of my program. So the only way is to call <plugins> method once, store returned objects list and then use them. Is much more convenient to have some accessor method to already created plugin objects.
On Wed Jun 03 06:39:40 2009, Alien wrote: Show quoted text
> I've found one inconvenient restriction in module. When I use > <instantiate> option, each call of method <plugins> creates new > instances of my plugins. This is not what I expect, I want to get the > same plugin objects in different points of my program. So the only way > is to call <plugins> method once, store returned objects list and then > use them. Is much more convenient to have some accessor method to > already created plugin objects.
This was a deliberate design decision - I didn't want to force people to incur the overhead of caching when they didn't need it. My suggestion would be to do something like this use Module::Pluggable instantiate => 'new', sub_name => '_plugins'; our %plugins; sub plugins { my $class = shift; return %plugins ||= $class->_plugins; } or, alternatively, sub class Module::Pluggable.
From: icestar [...] inbox.ru
Show quoted text
> This was a deliberate design decision - I didn't want to force people
to Show quoted text
> incur the overhead of caching when they didn't need it. My suggestion > would be to do something like this > > use Module::Pluggable instantiate => 'new', sub_name => '_plugins'; > > our %plugins; > sub plugins { > my $class = shift; > return %plugins ||= $class->_plugins; > } > > or, alternatively, sub class Module::Pluggable.
Thanks for your suggestion. Now I think that your design decision is right. :)