Skip Menu |

This queue is for tickets about the MooseX-Storage CPAN distribution.

Report information
The Basics
Id: 66730
Status: open
Priority: 0/
Queue: MooseX-Storage

People
Owner: Nobody in particular
Requestors: rsimoes [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.29
Fixed in: (no value)



Subject: import sub makes for difficulty in including MooseX::Storage in export modules
In particular, the $pkg variable in MooseX::Storage's import sub's `($pkg->can('meta')) || confess` line is set to the caller, which means an export module must be a Moose class itself or trigger that line's fatal second disjunct. One can write a dummy meta sub in the export module, but MooseX::Storage's import sub also calls `$pkg->meta->add_method`. The ultimate solution ended up being to call meta->add_method directly from within the export module, so that that "$pkg" could be set to the caller of the export module. A simple solution would be to merely remove the can('meta') test, but it would be extra swell if MooseX::Storage's import functionality came from Moose::Exporter!
Similar problem happens when applying the role at runtime. Work-around: use MooseX::Storage qw(); # avoid importing the Storage function use Moose::Util qw(apply_all_roles); use Point qw(); # a Moose object my $p = Point->new(x => 23, y => 42); $p->meta->add_method('Storage' => MooseX::Storage->meta->find_method_by_name('_injected_storage_role_generator') ); apply_all_roles($p, Point::Storage( format => [JSONpm => {json_opts => {pretty => 1}}]) ); print $p->freeze; #moose <haarg> i'd file a bug though for it to fix its exporter to not be so dumb