foo: bar
baz: 123
- ## In your class
+ ## In your class
package My::App;
use Moose;
-
- with 'MooseX::SimpleConfig';
-
- has 'foo' => (is => 'ro', isa => 'Str', required => 1);
+
+ with 'MooseX::SimpleConfig';
+
+ has 'foo' => (is => 'ro', isa => 'Str', required => 1);
has 'baz' => (is => 'rw', isa => 'Int', required => 1);
-
- # ... rest of the class here
-
- ## in your script
+
+ # ... rest of the class here
+
+ ## in your script
#!/usr/bin/perl
-
- use My::App;
-
- my $app = My::App->new_with_config(configfile => '/etc/my_app.yaml');
+
+ use My::App;
+
+ my $app = My::App->new_with_config(configfile => '/etc/my_app.yaml');
# ... rest of the script here
####################
###### combined with MooseX::Getopt:
- ## In your class
+ ## In your class
package My::App;
use Moose;
-
- with 'MooseX::SimpleConfig';
+
+ with 'MooseX::SimpleConfig';
with 'MooseX::Getopt';
-
- has 'foo' => (is => 'ro', isa => 'Str', required => 1);
+
+ has 'foo' => (is => 'ro', isa => 'Str', required => 1);
has 'baz' => (is => 'rw', isa => 'Int', required => 1);
-
- # ... rest of the class here
-
- ## in your script
+
+ # ... rest of the class here
+
+ ## in your script
#!/usr/bin/perl
-
- use My::App;
-
- my $app = My::App->new_with_options();
+
+ use My::App;
+
+ my $app = My::App->new_with_options();
# ... rest of the script here
## on the command line
Provided by the base role MooseX::ConfigFromFile. You can provide a
default configfile pathname like so:
- has +configfile ( default => '/etc/myapp.yaml' );
+ has '+configfile' => ( default => '/etc/myapp.yaml' );
+
+ You can pass an array of filenames if you want, but as usual the array
+ has to be wrapped in a sub ref.
+
+ has '+configfile' => ( default => sub { [ '/etc/myapp.yaml', '/etc/myapp_local.yml' ] } );
+
+ Config files are trivially merged at the top level, with the right-hand
+ files taking precedence.
CLASS METHODS
new_with_config