Subject: | Moose::Exporter synopsis just doesn't work |
Date: | Fri, 05 Dec 2014 17:35:22 +0000 |
To: | bug-Moose [...] rt.cpan.org |
From: | Robert Rothenberg <rrwo [...] cpan.org> |
I've tried using Moose::Exporter to add some syntactic sugar, but the
documentation does not help.
Adapting examples from the SYNOPSIS, eliminating the obvious missing examples:
Show quoted text
> package MyApp::Moose;
>
> use Moose ();
> use Moose::Exporter;
>
> Moose::Exporter->setup_import_methods(
> with_meta => [ 'has_rw' ],
> also => 'Moose',
> );
>
> sub has_rw {
> my ( $meta, $name, %options ) = @_;
> $meta->add_attribute(
> $name,
> is => 'rw',
> %options,
> );
> }
>
> 1;
and
Show quoted text> package MyApp::User;
>
> use MyApp::Moose;
>
> has 'name';
> has_rw 'size';
> thing;
>
> no MyApp::Moose;
>
> 1;
Then running (on Perl 5.20.1):
perl -I lib/ -MMyApp::User
gives me the error:
Show quoted text> Bareword "thing" not allowed while "strict subs" in use at
> lib/MyApp/User.pm line 7.
> Compilation failed in require.
> BEGIN failed--compilation aborted.