Subject: | Template::Generic:instance accessor generation doesn't work |
Given this small test script:
package Foo;
use Class::MakeMethods::Template::Hash(
new => [ 'new' ],
instance => [ 'instance', { class => 'Foo' } ],
);
A syntax check produces this:
Can't make method instance(): template specifies unknown behavior 'get_and_set' at Foo.pm line 4
BEGIN failed--compilation aborted at Foo.pm line 6.
The test suite for Class::MakeMethods::template doesn't cover the 'instance' Accessor, and the docs don't have a concrete example of how to use it, so it is possible that I'm just trying to invoke it incorrectly.
I came up with the above example because Template::Generic:instance imports everything from Template::Generic:object. If I replace 'instance' with 'object' in the above example, the code compiles clean.
Running the syntax check with -MCarp=verbose produces this stacktrace:
Can't make method instance(): template specifies unknown behavior 'get_and_set' at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods.pm line 267
Class::MakeMethods::_diagnostic called at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods/Template.pm line 11
Class::MakeMethods::Template::_diagnostic('make_bad_behavior','instance','get_and_set') called at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods/Template.pm line 388
Class::MakeMethods::Template::_behavior_builder('Class::MakeMethods::Template=HASH(0x81dea04)','get_and_set','HASH(0x81dd0d8)') called at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods/Template.pm line 265
Class::MakeMethods::Template::make_methods('Class::MakeMethods::Template=HASH(0x81dea04)','instance','HASH(0x814f2f4)') called at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods.pm line 138
Class::MakeMethods::make('Class::MakeMethods::Template::Hash','new','ARRAY(0x814f2d0)','instance','ARRAY(0x8134078)') called at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods.pm line 34
Class::MakeMethods::import('Class::MakeMethods::Template::Hash','new','ARRAY(0x814f2d0)','instance','ARRAY(0x8134078)') called at Foo.pm line 4
Foo::BEGIN() called at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods/Template/Hash.pm line 6
eval {...} called at /usr/local/lib/perl5/site_perl/5.8.0/Class/MakeMethods/Template/Hash.pm line 6
BEGIN failed--compilation aborted at Foo.pm line 6.
Thanks.