Very simple question:
package MyApp::Model::Foo;
use Moose;
use namespace::autoclean;
extends 'Catalyst::Model';
has 'firstname' => ( is => 'ro', isa => 'Str' ); # to be populated in config file
# ...
sub check_name {
my $self = shift;
my $firstname = $self->firstname;
# ...
}
When I call check_name()
from a test script, at the "$self->firstname" line I get the error Can't use string ("MyApp::Model::Foo") as a HASH ref while "strict refs" in use at reader MyApp::Model::Foo::firstname
. How am I supposed to use this?
I can't reproduce the test stuff as it's too extensive, but by the time I run the test script, I've called a setup script that loads the Catalyst application (and thus reads the Catalyst config file), deploys and populates database tables, etc.
The test script worked fine in the original version (which did not take a value from the config file; that's what I'm trying to do now; originally I passed in a value), and the relevant bit is simply
my $name_check = MyApp::Model::Foo->check_name();
ok(defined $name_check, "Name is OK");