Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: cymenvig [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.21
Fixed in: 0.22



Calling initialize in this example results in: Show quoted text
> perl Fruit.pm
Can't locate object method "new" via package "MooseX::Singleton::Role::Object" at /.../perl/lib/site_perl/5.10.0/MooseX/Singleton/Role/Object.pm line 13. If I change the last line of the initialize method in MooseX::Singleton::Role::Object from: return $class->SUPER::new(@args); To: return $class->new(@args); The attached works. I realize that isn't a complete solution. Am I using this incorrectly or should this work? Thanks! Cymen
Subject: Fruit.pm
#!/usr/bin/perl package Fruit; use Moose::Role; has 'type' => ( is => 'rw', isa => 'Str', #required => 1, ); 1; #----------------------------------------------------------- package SingleApple; use MooseX::Singleton; with 'Fruit'; has 'crispness' => ( is => 'rw', isa => 'Int', default => 5, ); 1; #----------------------------------------------------------- package main; #use SingleApple; my $a = SingleApple->initialize({ type=>'Golden Delicious' }); #my $a = SingleApple->instance({ type=>'Golden Delicious' }); print "Type: ", $a->type, "\n"; print "Crispness: ", $a->crispness, "\n";
The role is a total red herring. All that matters is that ->initialize is broken.