zigdon has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I thought I understood how SUPER works - but today I tried to override a method in a CDBI object, and things didn't happen as I expected.
I have a My::User.pm, which (among other columns), has a Password column. Since I'm hashing the password, I wanted to able to call $u->password("secret"), and have it stored in the database automatically hashed. So in my User.pm module, I tried to override the password method:
sub password { my $self = shift; if (@_) { # we're setting a value $_[0] = Digest::MD5::md5_base64($_[0]); } return $self->SUPER::password(@_); }
But when I try this, I get the following error:
Can't locate object method "password" via package "My::User" at My/Use +r.pm line 37.
So I have two questions:
-- zigdon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (z) SUPER and Class::DBI
by edoc (Chaplain) on Dec 30, 2003 at 22:10 UTC | |
|
Re: (z) SUPER and Class::DBI
by duct_tape (Hermit) on Dec 30, 2003 at 22:27 UTC | |
|
Re: (z) SUPER and Class::DBI
by PodMaster (Abbot) on Dec 31, 2003 at 07:08 UTC | |
by zigdon (Deacon) on Dec 31, 2003 at 13:52 UTC | |
|
Re: (z) SUPER and Class::DBI
by sgifford (Prior) on Dec 30, 2003 at 21:50 UTC | |
by zigdon (Deacon) on Dec 31, 2003 at 13:45 UTC |