in reply to Re: subclass and overridden constructor
in thread subclass and overridden constructor

that barfs even more ....
unknown processor AuthorizeNet (Can't locate Unleashed/AuthorizeCard/A +uthorizeNet.pm in @INC
and i do have the right mods installed. the test script ( sans subclassing ) works.

i'm going to have to dig around in Business::OnlinePayment's source, i guess.

Replies are listed 'Best First'.
Re: Re: Re: subclass and overridden constructor
by simonm (Vicar) on Dec 03, 2003 at 21:28 UTC
    Ah, sure enough -- if you look at the source of OnlinePayment.pm you'll see that it's got a very specific approach to subclassing already implemented.

    It might be straightforward to make a package that was a subclass of a specific processor, such as Unleashed::AuthorizeCard::AuthorizeNet inheriting from both your Unleashed::AuthorizeCard and Business::OnlinePayment::AuthorizeNet.

    If you want to dynamically handle whichever processor the end-user selects, you'll probably have to either generate subclasses on the fly, or use delegation rather than inheritance.

    (More generally, this illustrates one of the advantages of well-factored frameworks that use delegation internally; for example, I can imagine a version of Business::OnlinePayment that was divided into separate Transaction and Processor classes, which would allow you to subclass Transaction without worrying which Processor it was connecting to.)

      i looked at the source and realized that subclassing *wasn't* what i should be doing.

      i should have been writing a wrapper, not a subclass. so that's what i did, and stashed the Business::OnlinePayment object in the wrapper object. that takes care of the issue, and i just need an extra method call to access the processor object.

        You could use delegation to bypass that extra method call assuming you mean from the object users point of view