[Catalyst] overload/override sub? (Session::PerUser)
Matt S Trout
dbix-class at trout.me.uk
Tue Aug 7 13:51:54 GMT 2007
On Mon, Aug 06, 2007 at 09:42:28PM +0100, Ash Berlin wrote:
> Fernan Aguero wrote:
> > Hi,
> >
> > I'd like to overload (or would it be override?) the
> > merge_session_to_user sub in
> > Catalyst::Plugin::Session::PerUser to be able to guide the
> > hash merge (i.e. create new hash value keys for conflicting
> > keys).
> >
> > Now, where and how should I do the overriding? Excuse my ignorance
> > ... but I've never done this and searching for 'Perl
> > overload' always gets me to instructions on how to overload
> > built-in operators ...
> >
> > Thanks in advance,
> >
> > Fernan
>
> Redefine is the term in perl-lingua.
Not really, it's just subclassing.
Catalyst plugins (like DBIC components) just end up as extra superclasses
> In MyApp.pm:
>
> {
> no warnings 'redefine';
# this line is completely pointless.
>
> sub merge_session_to_user {
> # your new sub
>
> # ...
>
> # To call the previous implementation if you should want it:
> # $self->NEXT::merge_session_to_user(@args);
> }
> }
>
> The key thing to remember here is that all Cat plugins 'pollute' the $c
> namespace, which isa Myapp.
They end up on your @ISA, this polluting the namespace of potential method
names, but they don't pollute the MyApp package directly - that level of
stupidity I haven't seen since Class::DBI::Plugin::*
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/
More information about the Catalyst
mailing list