Skip Menu |

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

Report information
The Basics
Id: 87019
Status: new
Priority: 0/
Queue: MooseX-Singleton

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

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



MooseX::Singleton when dealing with attributes that don't have an explicit accessor set (but do have delegates set) blows up when trying to access that attribute (via the delegate obviously). The simple work around is to always create an accessor ... but *sigh*. Attached is the test script that outputs this error: # Failed test 'MooseX::Singleton without accessor works' # at xt/mx-singleton-delegate.t line 49. # got: 'You must pass a package name and it cannot be blessed at /home/chrisprather/wonk/extlib/lib/perl5/x86_64- linux-gnu-thread-multi/Class/MOP/Class.pm line 44. # Class::MOP::Class::initialize('Class::MOP::Class', '') called at /home/chrisprather/wonk/extlib/lib/perl5/x86_64-l inux-gnu-thread-multi/Class/MOP/Attribute.pm line 297 # Class::MOP::Attribute::get_raw_value('Moose::Meta::Attribute=HASH(0x13c98c0)', 'Baz') called at /home/chrisprather /wonk/extlib/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Attribute.pm line 291 # Class::MOP::Attribute::get_value('Moose::Meta::Attribute=HASH(0x13c98c0)', 'Baz') called at /home/chrisprather/won k/extlib/lib/perl5/x86_64-linux-gnu-thread-multi/Moose/Meta/Attribute.pm line 861 # Moose::Meta::Attribute::get_value('Moose::Meta::Attribute=HASH(0x13c98c0)', 'Baz') called at /home/chrisprather/wo nk/extlib/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Attribute.pm line 198 # Class::MOP::Attribute::__ANON__('Baz') called at /home/chrisprather/wonk/extlib/lib/perl5/x86_64-linux-gnu-thread- multi/Moose/Meta/Method/Delegation.pm line 92 # Baz::foo('Baz') called at xt/mx-singleton-delegate.t line 49 # main::__ANON__() called at /home/chrisprather/wonk/extlib/lib/perl5/Test/Fatal.pm line 23 # Test::Fatal::__ANON__() called at /home/chrisprather/wonk/extlib/lib/perl5/Try/Tiny.pm line 71 # eval {...} called at /home/chrisprather/wonk/extlib/lib/perl5/Try/Tiny.pm line 67 # Try::Tiny::try('CODE(0x65a030)', 'Try::Tiny::Catch=REF(0x662980)') called at /home/chrisprather/wonk/extlib/lib/pe rl5/Test/Fatal.pm line 30 # Test::Fatal::exception('CODE(0x13bbd28)') called at xt/mx-singleton-delegate.t line 49 # ' # expected: undef # Looks like you failed 1 test of 3.
Subject: mx-singleton-delegate.t
#!/usr/bin/env perl use strict; use Test::More; use Test::Fatal; { package Foo; use Moose; sub foo {'FOO'} } { package Bar; use MooseX::Singleton; has bar => ( isa => 'Foo', is => 'ro', default => sub { Foo->new() }, handles => [qw(foo)], ); } { package Bam; use Moose; has bar => ( isa => 'Foo', default => sub { Foo->new() }, handles => [qw(foo)], ); } { package Baz; use MooseX::Singleton; has bar => ( isa => 'Foo', default => sub { Foo->new() }, handles => [qw(foo)], ); } is exception { Bar->foo }, undef, 'MooseX::Singleton with accessor works'; is exception { Bam->new->foo }, undef, 'Moose without accessor works'; is exception { Baz->foo }, undef, 'MooseX::Singleton without accessor works'; done_testing;