Subject: | Moo::Object->meta->can() dies. |
I was just doing bulk introspecting of various things, and in doing so, tried to introspect "Moo::Object"
in the general case this logic is fine:
However, when $class happens to be "Moo::Object", the usually safe approach of calling "can" explodes in your face.
Instead, calling "can" results in:
And equivalent test attached.
in the general case this logic is fine:
sub example { my ($class) = shift; return unless if $class->can('meta'); return unless $class->meta->can("somethinghere"); .... }
However, when $class happens to be "Moo::Object", the usually safe approach of calling "can" explodes in your face.
Instead, calling "can" results in:
Can't call method "all_attribute_specs" on an undefined value at .../Moo/HandleMoose.pm line 70
Relevant backtrace lines are:
Moo::HandleMoose::inject_real_metaclass_for('Moo::Object') called at Moo/HandleMoose/FakeMetaClass.pm line 12 Moo::HandleMoose::FakeMetaClass::can('Moo::HandleMoose::FakeMetaClass=HASH(0x1141ff8)') called at /tmp/moofail.pl line 12
And equivalent test attached.
Subject: | moofail.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Test::More;
use Test::Fatal;
use Moo::Object;
ok( Moo::Object->can('meta'), 'Moo::Object can meta');
is( exception { Moo::Object->meta->can() } , undef, "Moo::Object->meta->can doesn't explode" );
done_testing;