Re: changing the default base class

[email protected] (Jonathan Swartz)
Newsgroups perl.moose
Message-ID <[email protected]>
Also Matt Trout suggests the goto & form, which I forgot about, but  
is designed exactly for the purpose of hiding a call level.

 > sub import {
 >
 >  <do stuff>
 >
 >   goto &Moose::import;
 >
 > }
 >
 > presto. caller() is correct. I'm doing this for Reaction::Class,  
which is part of a metamodel-driven set of tools I'm building for web  
dev atop the Catalyst framework.

On Nov 17, 2006, at 11:40 AM, Todd Hepler wrote:

> Jonathan Swartz wrote:
> >
> >     package My::Person;
> >     use My::Moose;    # automatically sets superclass to
> > My::Moose::Object, instead of Moose::Object
>
> I have wanted something similar, and ended up with this:
>
> package My::Moose;
> sub import {
>     my $caller = caller();
>     eval qq{
>         package $caller;
>         use Moose;
>         extends 'My::Moose::Object';
>     };
>     die $@ if $@;
> }
>
> Though, there's gotta be a better way...
>
> Stevan Little wrote:
>> Jonathan,
>> On Nov 17, 2006, at 7:45 AM, Jonathan Swartz wrote:
>>> Or perhaps I could use Moose::Policy for this. But then each  
>>> class would read
>>>
>>>     package My::Person;
>>>     use Moose::Policy 'My::Moose::Policy';
>>>     use Moose;
>> Yes, this would be the way to go about it (kind of).
>>> Yuck. It seems like a significant blow to the syntactic single- 
>>> use-line beauty of Moose, and a violation of DRY.
>> I agree it is uglier, however, I don't see it as a violation of DRY.
>
> It might be nice if you could leave out the "use Moose".  I think  
> that's the repetition.
>
> -Todd
>
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.