Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    MooseX::Attributes::Curried 0.03

    Download button

    No screenshots available
    Downloads: 256  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Shawn M Moore | More programs
    Perl Artistic License / FREE
    November 14th, 2009, 17:29 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    MooseX::Attributes::Curried description

    Curry your "has"es

    MooseX::Attributes::Curried is a Perl module that lets you define curried versions of "has" in Moose. If many of your attributes share the same options, especially across multiple classes, then you can refactor those options away into a curried has.

    Typical usage of this extension is to create a standalone "has library" module. If you only need a curried has for one class, then you might as well just define a sub has_datetime { has(...) } in that class.

    When you use your "has library", you can customize each curried has further by specifying additional options on your import line, like so:

     use MyAttrs (
     has_datetime => {
     is => 'ro',
     },
     has_datetime => {
     -as => 'needs_datetime',
     required => 1,
     },
     );


    Your "defaults" for the attribute can also be a code reference. This code reference will receive both the additional specializations performed when the curried attribute was imported, as well as any additional specializations used in the individual attribute. This is immensely powerful, see t/007-smart-has.t for a taste.

    SYNOPSIS

     package MyAttrs;
     use MooseX::Attributes::Curried (
     has_datetime => {
     isa => 'DateTime',
     default => sub { DateTime->now },
     },
     has_rw => {
     is => 'rw',
     },
     );

     package My::Class;
     use Moose;
     use MyAttrs;

     has_datetime 'birthday' => (
     is => 'ro',
     );

     has_rw 'age' => (
     isa => 'Int',
     );



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    MooseX attributes | define curried | Perl module | Moose | curried | attributes

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM