[Catalyst] using Plugin::Singleton and testing

Matt S Trout dbix-class at trout.me.uk
Wed Nov 15 12:26:02 GMT 2006


Daniel McBrearty wrote:
> I have a method in a model that goes like this:
> 
> sub do_something {
>    my ($self, $my_var) = @_;
> 
>    $my_var = MyApp->context->stash->{my_var} unless defined $my_var;
>    die "my_var not defined" unless defined $my_var;

Plugin::Singleton considered a really, really, really bad idea.

Don't use it.

Implement COMPONENT or ACCEPT_CONTEXT (see Catalyst::Component) as appropriate 
instead.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list