in reply to MooseX::SimpleConfig: role attribute cannot be made lazy
The problem is that MooseX::ConfigFromFile (the "parent" role of MooseX::SimpleConfig) is doing some pretty odd stuff with the configfile attribute, such as trying to call the default before an instance has been created (see here for details). What you are trying to do simply won't work because of this. Probably the simplest alternative is to do something like:
Obviously shorten 'new_from_config_shortname' to something more appropriate, but that should give you what you want.#!/usr/bin/perl package My::Config; use Moose; with 'MooseX::SimpleConfig'; sub new_from_config_shortname { my ($class, $filename) = @_; $class->new_from_config( configfile => '/some/path/' . $filename . + ".yaml" ); } my $config = My::Config->new_from_config_shortname("config");
-stvn
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: MooseX::SimpleConfig: role attribute cannot be made lazy
by lune (Pilgrim) on Oct 26, 2011 at 17:32 UTC | |
by stvn (Monsignor) on Oct 27, 2011 at 16:28 UTC |
In Section
Seekers of Perl Wisdom