Subject: | Ambient package for inline code should probably be Type::Tiny or some dummy package, and not the class which is being generated |
## This generates a warning, but I've had other cases where
## similar things completely die...
##
use strict;
use warnings;
BEGIN { $ENV{PERL_ONLY} = 1 }; # no XS
package Foo {
use Moo;
use MooX::TypeTiny;
use Types::Standard qw(HashRef Str);
has _data => (
is => 'ro',
isa => HashRef[Str],
required => 1,
init_arg => 'data',
);
sub values {
@_==1 or die 'too many parameters';
CORE::values %{shift->_data};
}
sub keys {
@_==1 or die 'too many parameters';
CORE::keys %{shift->_data};
}
__PACKAGE__->meta->make_immutable;
}
my $obj = Foo->new(data => {foo => 42});
print "$_\n" for $obj->values;
#require B::Deparse;
#print B::Deparse->new->coderef2text(\&Foo::new);