Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 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::AttributeDefaults 0.02

    Download button

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

    License / Price:

    Last Updated:

    Category:
    Paul Driver | More programs
    Perl Artistic License / FREE
    November 18th, 2008, 16:50 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    MooseX::AttributeDefaults description

    Role to provide default option for your attribute metaclasses

    MooseX::AttributeDefaults is a Perl module that provides default option for your attribute metaclasses.

    SYNOPSIS

    Although you can do similar things by overriding attributes in subclasses of Moose::Meta::Attribute, there are a couple of gotchas (as of this writing, for instance, overriding 'is' does nothing at all). This role abstracts the implementation details of the available workarounds.

     package My::Custom::Metaclass;
     use Moose;

     extends 'Moose::Meta::Attribute';
     with 'MooseX::AttributeDefaults';

     sub default_options {
     my ($class, $name) = @_;
     
     return (
     is => 'ro',
     isa => 'Str',
     default => "default value for $name";
     );
     }

     package Some::Class;
     use Moose;

     has 'attr' => (
     metaclass => 'My::Custom::Metaclass',
     predicate => 'has_attr',
     );

     # 'attr' is a ro string with "default value for attr" as its
     # default and a 'has_attr' predicate

     ### Or as a trait instead of a metaclass
     
     package Acme::Common::Array;
     use Moose::Role;

     with qw(MooseX::AttributeDefaults);

     sub default_options {
     is => 'ro',
     isa => 'ArrayRef',
     default => sub { [] },
     }

     package Some::Class;
     use Moose;
     use MooseX::AttributeHelpers;

     has attr => (
     metaclass => 'Collection::Array',
     traits => [qw(Acme::Common::Array)],
     provides => {
     'push' => 'add_attr',
     },
     );



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    attribute metaclasses | Perl module | Perl | attribute | metaclasses

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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