On Sun, Jul 18, 2010 at 15:11, Dave Rolsky <[email protected]> wrote:
> On Sun, 18 Jul 2010, Ævar Arnfjörð Bjarmason wrote:
>
>> 2b54d2a6b7bf40c4408ffbc117f6b6d77ee35c67 by Dave Rolsky broke this
>> DWIM MX::Getopt program:
>>
>> package Xailo;
>> use 5.012;
>> use Any::Moose;
>> with any_moose('X::Getopt');
>>
>> has args => (
>> documentation => "Arguments for the engine class",
>> isa => 'HashRef',
>> coerce => 1,
>> is => "ro",
>> default => sub { +{} },
>> );
>>
>> sub run {
>> my ($self) = @_;
>>
>> say "$_ = $self->{args}{$_}" for sort keys %{ $self->{args} };
>> }
>>
>> package xailo;
>> Xailo->new_with_options->run;
>>
>> Before:
>>
>> foo = bar
>> this = that
>>
>> After:
>>
>> Attribute (args) does not pass the type constraint because:
>> Validation failed for 'HashRef' with value foo at
>>
>> /home/v-perlbrew/perl5/perlbrew/perls/perl-5.13.2/lib/site_perl/5.13.2/x86_64-linux/Moose/Meta/Attribute.pm
>> line 746
>>
>> Can this be made to work instead of dying? Perhaps a coercion needs to
>> be added to MooseX::Getopt?
>
> Well, it shouldn't die any more, just warn. But it still should be fixed.
>
> I don't understand why you're passing "coerce => 1" there. Where is the
> coercion defined?
Indeed it should. When I wrote this I /thought/ that the coerce
argument was what was doing the "foo=bar" -> { foo => "bar" }
magic. But evidently not, it works just fine without it.
So, false alarm, and this fixes it:
http://github.com/avar/hailo/commit/4dbac78b07a