[cgiapp] Proposal: Change CGI::Snapp's base class from Hash::FieldHash to Moos (sic)
Mark Stosberg
mark at summersault.com
Tue Dec 11 09:29:43 EST 2012
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();
###
More information about the cgiapp
mailing list