Matt S Trout dbix-class at
Sat May 3 22:45:19 BST 2008

On Mon, Apr 28, 2008 at 04:13:29PM -0500, Ian Malpass wrote:
> Peter Corlett wrote:
> >On Mon, Apr 28, 2008 at 11:41:01AM -0500, Ian Malpass wrote:
> >[...]
> >>I want to inherit from a base class, but I want to not inherit methods
> >>foo() and bar(). I could over-ride these with methods that die(), but
> >>can() would still see them.
> >
> >In that case, you do not want to inherit from a base class. You want to
> >encapsulate it in another class that only exposes the API that you wish to
> >expose.
> Actually, in the particular case of the problem I'm working on now, I 
> think I'm going to add in another base class to inherit from, and the 
> subclass that doesn't want those methods won't use that base class.
> But that approach won't work all the time - is there anything out on 
> CPAN that helps with the encapsulate-and-expose approach? Or any design 
> recommendations?

use Moose;

has _wrapped => (isa => 'Some::Class', handles => qr/^(?!method1$|method2$)/);

That'll delegate every method except for method1 and method2 :)

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director          
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?  

More information about the mailing list