Thanks!++ Not only was I unaware of MooseX::Types::Path::Class, I was completely missing out on Path::Class.
It looks like I've got enough wheels sitting around here to build my own space shuttle crawler.
| [reply] |
I am trying to use MooseX::SimpleConfig and I cannot tell from the docs if this module actually sets your Moose attributes to the respective config values or not ... do you know?
When I set up a config file and and Moose class -- and then I instantiate and dump it -- all I see in the hash ref is a key for 'configfile' and the "attributes" inside my config file are not there.
Isn't the point of this module to set those values for me? So that I do not have to parse the config file nor explicitly set the attributes myself? | [reply] |
From what I can tell, there are two things you need to do:
- Create your own role that implements the get_config_from_file role, using a config loader of your choice (take a look at Config-Any).
- Use new_from_config instead of new. This method will initialize your object with the values returned by the get_config_from_file method.
The synopsis has a more complex example of this.
Ordinary morality is for ordinary people. -- Aleister Crowley
| [reply] |
Too add to what phaylon said ...
I recommend looking closer at the SYNOPSIS for this module. It does not make &new magical (this is something we strongly discourage in Moose, &new should behave consistently across all classes), instead it provides an alternate constructor called &new_with_config, which expects the path of a config file, like so ...
my $app = My::App->new_with_config(configfile => '/etc/my_app.yaml');
This module also integrates with MooseX::Getopt such that the usual &new_with_options constructor that MooseX::Getopt supplies will accept and do the right thing for the -configfile option.
MooseX::SimpleConfig is a Config::Any powered extension of MooseX::ConfigFromFile, which provides the basic building blocks. It is actually a rather simple setup, a quick read of the source of both these modules should tell you exactly what is going on.
| [reply] [d/l] [select] |