lune has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I want to create a class that reads in simple yaml config files, based on an argument.
With MooseX::SimpleConfig I want the path to be constructed from the argument and some base path already known. However, it seems the role Attribute '+configfile' cannot be made lazy and is always being created before anything else:
This code gives me:#!/usr/bin/perl package My::Config; use Moose; with 'MooseX::SimpleConfig'; has filename => ( is => 'ro', isa => 'Str', required => 1, ); has '+configfile' => ( default => sub { my $self = shift; '/some/path/' . $self->filename + . ".yaml"; }, lazy => 1, ); my $config = My::Config->new_with_config( filename => "config");
Can't call method "filename" on an undefined value at ./myconf3.pl line 11.
Or is there an error on my side?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: MooseX::SimpleConfig: role attribute cannot be made lazy
by stvn (Monsignor) on Oct 26, 2011 at 17:04 UTC | |
by lune (Pilgrim) on Oct 26, 2011 at 17:32 UTC | |
by stvn (Monsignor) on Oct 27, 2011 at 16:28 UTC | |
Re: MooseX::SimpleConfig: role attribute cannot be made lazy
by choroba (Cardinal) on Oct 26, 2011 at 15:13 UTC | |
Re: MooseX::SimpleConfig: role attribute cannot be made lazy
by zby (Vicar) on Oct 27, 2011 at 10:20 UTC |
Back to
Seekers of Perl Wisdom