jeteve has asked for the wisdom of the Perl Monks concerning the following question:
Hi wise fellow monks.
In one of my projects, I implemented a subclass of HTTP::Requests to add extra attributes and methods to it. Basically as this:
package My::HTTPRequest ; use base qw/HTTP::Request/ ; sub new{ my ($class) = shift ; my $self = $class->SUPER::new(@_) ; $self->{'myA'} = undef ; return bless $self, $class ; } sub myM{ my ($self) = @_ ; ... } ... 1;
Everything is fine appart this problem: I got another module that produce standard HTTP::Requests objects and I want to turn those into my My::HTTPRequests. Basically, what I want to have is this:
my $httpr = AnotherModule::f() ; # $httpr is a plain HTTP::Request object my $ownHttpr = transform($httpr) ; # $ownHttpr should be an instance of My::HTTPRequest with all the prop +erties of $httpr .
According to you, what is the best way to implement the function transform ?
-- Nice photos of naked perl sources here !
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to turn an object in my own subclass
by davorg (Chancellor) on Sep 05, 2006 at 10:14 UTC | |
by jeteve (Pilgrim) on Sep 05, 2006 at 10:29 UTC | |
by Hue-Bond (Priest) on Sep 05, 2006 at 13:27 UTC | |
|
Re: How to turn an object in my own subclass
by jdporter (Paladin) on Sep 05, 2006 at 15:08 UTC |