On Thu, Jul 15, 2010 at 10:11:04AM -0700, Karen Etheridge wrote:
> On Wed, Jul 14, 2010 at 09:28:35PM -0500, Jesse Luehrs wrote:
> > Nope... you can't magically turn a class (even a non-Moose class) into a
> > role... roles just don't work like that. Sticking with extends is really
> > your only option for dealing with non-Moose code.
> 
> I see a few options:
> 
> 1. copy your framework code into a Moose role (i.e. "refactor")
> 2. import the functions from the framework into a Moose role, using
> Exporter.
> 3. create a Moose role which has one attribute, an object handle which is
> an instantiation of your framework, and use delegations (i.e. the 'handles'
> option) to tie methods from the role into the framework class.

2 won't work, because Moose treats exports different from methods (this
is why you can do "use Scalar::Util 'reftype'" in two different roles
and not get a method conflict). And I assumed that if 1 was reasonable,
we wouldn't really even be having this discussion(: But it's true,
delegation would be another potential option.

-doy

Reply via email to