Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Favorite MooseX Modules?

by pileofrogs (Priest)
on Aug 05, 2009 at 16:16 UTC ( [id://786154]=perlquestion: print w/replies, xml ) Need Help??

pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, Monks!

I recently found myself holding a big fat wheel, as in something I had re-invented. I assume there's a MooseX module out there that will implement a persistent string, maybe even an integer and possibly even a timestamp? Anyway, the real question is about avoiding being a wheelwright again.

What are your favourite MooseX modules? I think I need to familiarise myself with the stuff that's already out there. I use MooseX::AttributeHelpers already. I've read Moose::Manual::MooseX. Others you find yourself using?

Replies are listed 'Best First'.
Re: Favorite MooseX Modules?
by stvn (Monsignor) on Aug 05, 2009 at 19:20 UTC
      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?

        From what I can tell, there are two things you need to do:

        1. 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).
        2. 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

        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.

        -stvn
Re: Favorite MooseX Modules?
by FunkyMonk (Chancellor) on Aug 05, 2009 at 16:38 UTC
Re: Favorite MooseX Modules?
by merlyn (Sage) on Aug 05, 2009 at 16:29 UTC
    I've just recently been introduced (by my client!) to MooseX::Declare. Nice.

    -- Randal L. Schwartz, Perl hacker

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Re: Favorite MooseX Modules?
by Mouser (Initiate) on Aug 19, 2009 at 00:34 UTC
    MooseX::Struct FTW! I wanted to convert loads of Class::Struct code to something better and found out about Moose via MooseX::Struct. It made the conversion PAINLESS and now i'm in love with Moose and spreading it around like the flu.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-20 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found