Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: MooseX::SimpleConfig: role attribute cannot be made lazy

by stvn (Monsignor)
on Oct 26, 2011 at 17:04 UTC ( [id://933942]=note: print w/replies, xml ) Need Help??


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:

#!/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");
Obviously shorten 'new_from_config_shortname' to something more appropriate, but that should give you what you want.

-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

    Thank you, this works - except the call to "new_from_config" should read "new_with_config"

    Should this be reported as an error in MooseX::SimpleConfig?

      Should this be reported as an error in MooseX::SimpleConfig?

      You can, but the original author is mostly AWOL and the maintainer might not be interested in untangling this mess. If nothing more it can become a documentation caveat.

      -stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://933942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-23 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found