[Catalyst] overload/override sub? (Session::PerUser)
Fernan Aguero
fernan at iib.unsam.edu.ar
Mon Aug 6 23:08:36 GMT 2007
| 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.
Thanks for the clarification ...
| In MyApp.pm:
|
| {
| no warnings 'redefine';
|
| 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.
|
| HTH
| Ash
and thanks for the code example.
I have already redefine the sub and it's working!
Thanks again,
Fernan
More information about the Catalyst
mailing list