Extends type questions

[email protected] ("Christopher Brown")
Newsgroups perl.moose
Message-ID <[email protected]>
Hi All,

What is the best way to moosify an existing CPAN class and all the classes
called by this class.  I know that *extends* works:

package MooseX::Module::A;
use Moose;
extends 'Module::A';


package MooseX::Module::B;
use Moose;
extends 'Module::B';

sub my_b_extension  {
  ...
}


But how do you extend both modules when Module::A relies on and calls
Module::B?  Such as.

package Module::A;.

sub create_b {
    my $self = shift;
    $self->{b} = Module::B->new();
}

...

Now in:

package main;
use MooseX::Module::A;
use MooseX::Module::B;

my $a = Moose::X::Module::A->new();    # Cool
$a->create_b;                                          # Cool
$a->{b}->my_b_extension();                   # FAIL!

In this scenario, I will not see *my_b_extension*.  In normal, non-Moose
Perl, I would:

package Module::AX;
use *base* 'Module::A';
...

package Module::BX;
use *base* 'Module::B';
...

Thanks in Advance,

Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.