Re: changing the default base class

[email protected] (Todd Hepler)
Newsgroups perl.moose
Message-ID <[email protected]>
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.