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> |
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