[cgiapp] Proposal: Change CGI::Snapp's base class from Hash::FieldHash to Moos (sic)

Ron Savage ron at savage.net.au
Tue Dec 11 15:39:43 EST 2012


Hi

Amazing. I don't get it get.

On 12/12/12 01:29, Mark Stosberg wrote:
> On 12/10/2012 06:05 PM, Ron Savage wrote:
>> Hi Mark
>>
>> On 11/12/12 08:38, Mark Stosberg wrote:
>>> On 12/10/2012 04:27 PM, Ron Savage wrote:
>>>> Hi Mark
>>>>
>>>> Ah, yes. No 'use Moo', means new() is not generated, so you don't end up
>>>> with a class.
>>>
>>> And the class-less-ness makes it a problem for putting BUILD in a
>>> Moo::Role?
>>
>> Yes. The role has a BUILD() from when it was a class:
>>
>> Can't locate object method "new" via package "Local::Config" at
>> scripts/test.config.pl line 17.
>
> I just tried putting together a Moo::Role with a BUILD method in it, and
> it worked... producing the same result as Moose did.
>
> See here:
>
> ###
>
> use 5.14.0;
>
> package My::Moose::Role {
>      use Moose::Role;
>      sub BUILD { shift->result("in My Role") }
> }
> package My::Moose {
>      use Moose;
>      has 'result' =>  (is =>  'rw');
>      with 'My::Moose::Role';
> }
> package My::Moo::Role {
>      use Moo::Role;
>      sub BUILD { shift->result("in My Role") }
> }
> package My::Moo {
>      use Moo;
>      has 'result' =>  (is =>  'rw');
>      with 'My::Moo::Role';
> }
>
> use Test::More;
>
> my $moose = My::Moose->new;
> my $moo   = My::Moo->new;
>
> is($moose->result,$moo->result,
>      "Moose and Moose support BUILD in roles the same?");
>
> done_testing();
>
> ###

-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622


More information about the cgiapp mailing list