Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

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

Report information
The Basics
Id: 58083
Status: open
Priority: 0/
Queue: MooseX-Singleton

People
Owner: Nobody in particular
Requestors: christian.westgaard [...] redpill-linpro.com
Cc:
AdminCc:

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



Subject: Can't locate object method "instance" via package
Date: Thu, 3 Jun 2010 10:33:24 +0200 (CEST)
To: bug-MooseX-Singleton [...] rt.cpan.org
From: Christian Westgaard <christian.westgaard [...] redpill-linpro.com>
Download (untitled) / with headers
text/plain 1.3k
I don't read japanese, but I have the same problem as this guy, with version (0.22) http://blog.kzfmix.com/entry/1240315321 $ ./ms.pl XXX at ./ms.pl line 16. Can't locate object method "instance" via package "Sng" at ./ms.pl line 18. $ cat ms.pl #!/usr/bin/perl package Foo; use Moose; sub p { return "XXX" } package Sng; use MooseX::Singleton; extends 'Foo'; package main; my $sng_new = Sng->new(); warn $sng_new->p(); my $sng_instance = Sng->instance; warn $sng_instance->p(); -- Here's what I'm trying to do: package Schema; use MooseX::Singleton; use MooseX::NonMoose; extends 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces; # Schema/Result/*.pm =cut sub BUILD { my $self = shift; my $schema = $self->connect( $self->_config->db_dsn, $self->_config->db_user, $self->_config->db_password ); #print Data::Dumper::Dumper( $schema ), "\n"; exit; return $schema; } =cut no Moose; __PACKAGE__->meta->make_immutable; 1; -- package Role::Persist; use Moose::Role; use Schema; has _schema => ( is => 'ro', isa => 'Schema', builder => '_build_schema', ); sub _build_schema { my $instance = Schema->instance; print Data::Dumper::Dumper( $instance ), "\n"; exit; } 1; -- Christian Westgaard Test Specialist and Senior Systems Developer Redpill Linpro AS - Changing the game Mobil: +47 40 40 14 35
Download (untitled) / with headers
text/plain 507b
Show quoted text
> Can't locate object method "instance" via package "Sng" at ./ms.pl > line 18.
I believe the problem is that MooseX::Singleton gives you a subclass of an anonymous class and then extends clears out the class' @ISA. The workaround is #!/usr/bin/perl package Foo; use Moose; sub p { return "XXX" } package Sng; BEGIN { use Moose; extends 'Foo'; } use MooseX::Singleton; package main; my $sng_new = Sng->new(); warn $sng_new->p(); my $sng_instance = Sng->instance; warn $sng_instance->p();
Download (untitled) / with headers
text/plain 651b
Bump! Also running into this issue. On Sun Nov 27 05:56:58 2011, KAARE wrote: Show quoted text
> > Can't locate object method "instance" via package "Sng" at ./ms.pl > > line 18.
> > I believe the problem is that MooseX::Singleton gives you a subclass of > an anonymous class and then extends clears out the class' @ISA. > > The workaround is > > #!/usr/bin/perl > package Foo; > use Moose; > > sub p { return "XXX" } > > package Sng; > > BEGIN { > use Moose; > extends 'Foo'; > } > > use MooseX::Singleton; > > > package main; > > my $sng_new = Sng->new(); > warn $sng_new->p(); > > my $sng_instance = Sng->instance; > warn $sng_instance->p();


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.