Skip Menu |

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

Report information
The Basics
Id: 41078
Status: resolved
Priority: 0/
Queue: MooseX-Singleton

People
Owner: stevan.little [...] gmail.com
Requestors: whjackson [...] gmail.com
Cc:
AdminCc:

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



Subject: Moose::Policy::FollowPBP breaks MooseX::Singleton
When using Moose::Policy::FollowPBP, MooseX::Singleton fails with: Can't locate object method "existing_singleton" via package "Moose::Meta::Class" at <snip>/cpan_lib/lib/perl5/site_perl/5.8.5/MooseX/Singleton/Object.pm line 22. Here is the program used to generate the error above: package MyApp; use Moose::Policy 'Moose::Policy::FollowPBP'; use MooseX::Singleton; package main; my $instance = MyApp->instance; __END__ Moose version: 0.61 Perl version: 5.8.5
Whitney, What is happening is that both MooseX::Singleton and Moose::Policy are trying to define the metaclass. Because Moose::Policy comes first in load order it is winning out and so when MooseX::Singleton::Object goes looking for the singleton it can't find it. This is surely a bug, but the only way to solve it is a larger re-write of Moose::Policy to use the new Moose::Exporter infastructure. Currently I am very busy with work and so have little time to spare, I would however be happy to accept a patch if you were so inclined. In the meantime your problem can be pretty easily solved by using the Moose::Policy::FollowPBP manually when using it with MooseX::Singleton, like so: package MyApp; use MooseX::Singleton; use Moose::Policy::FollowPBP; has 'foo' => ( metaclass => 'Moose::Policy::FollowPBP::Attribute', is => 'rw', isa => 'Str' ); package main; my $instance = MyApp->instance; $instance->set_foo("FOOOO"); print $instance->get_foo(); - Stevan On Wed Nov 19 19:17:34 2008, whjackson@gmail.com wrote: Show quoted text
> When using Moose::Policy::FollowPBP, MooseX::Singleton fails with: > > Can't locate object method "existing_singleton" via package > "Moose::Meta::Class" at > <snip>/cpan_lib/lib/perl5/site_perl/5.8.5/MooseX/Singleton/Object.pm > line 22. > > Here is the program used to generate the error above: > > package MyApp; > > use Moose::Policy 'Moose::Policy::FollowPBP'; > use MooseX::Singleton; > > package main; > > my $instance = MyApp->instance; > __END__ > > Moose version: 0.61 > Perl version: 5.8.5 >
Subject: Re: [rt.cpan.org #41078] Moose::Policy::FollowPBP breaks MooseX::Singleton
Date: Wed, 19 Nov 2008 21:38:30 -0600
To: bug-MooseX-Singleton [...] rt.cpan.org
From: "Whitney Jackson" <whjackson [...] gmail.com>
Thanks for the explanation and workaround. I adjusted my code as you suggested and it seems to have worked. Show quoted text
> This is surely a bug, but the only way to solve it is a larger re-write of Moose::Policy to use > the new Moose::Exporter infastructure. Currently I am very busy with work and so have little > time to spare, I would however be happy to accept a patch if you were so inclined.
When I have some free time I'll give it a shot. Thanks again! Whitney On Wed, Nov 19, 2008 at 7:23 PM, Stevan Little via RT <bug-MooseX-Singleton@rt.cpan.org> wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=41078 > > > Whitney, > > What is happening is that both MooseX::Singleton and Moose::Policy are trying to define the > metaclass. Because Moose::Policy comes first in load order it is winning out and so when > MooseX::Singleton::Object goes looking for the singleton it can't find it. > > This is surely a bug, but the only way to solve it is a larger re-write of Moose::Policy to use > the new Moose::Exporter infastructure. Currently I am very busy with work and so have little > time to spare, I would however be happy to accept a patch if you were so inclined. > > In the meantime your problem can be pretty easily solved by using the > Moose::Policy::FollowPBP manually when using it with MooseX::Singleton, like so: > > package MyApp; > use MooseX::Singleton; > use Moose::Policy::FollowPBP; > > has 'foo' => ( > metaclass => 'Moose::Policy::FollowPBP::Attribute', > is => 'rw', > isa => 'Str' > ); > > package main; > > my $instance = MyApp->instance; > $instance->set_foo("FOOOO"); > print $instance->get_foo(); > > - Stevan > > > > > On Wed Nov 19 19:17:34 2008, whjackson@gmail.com wrote:
>> When using Moose::Policy::FollowPBP, MooseX::Singleton fails with: >> >> Can't locate object method "existing_singleton" via package >> "Moose::Meta::Class" at >> <snip>/cpan_lib/lib/perl5/site_perl/5.8.5/MooseX/Singleton/Object.pm >> line 22. >> >> Here is the program used to generate the error above: >> >> package MyApp; >> >> use Moose::Policy 'Moose::Policy::FollowPBP'; >> use MooseX::Singleton; >> >> package main; >> >> my $instance = MyApp->instance; >> __END__ >> >> Moose version: 0.61 >> Perl version: 5.8.5 >>
> > > > >
Use the shiny new MooseX::FollowPBP, which is more cooperative with other modules. Moose::Policy is deprecated.