The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Moose::Role - The Moose Role

SYNOPSIS

  package Eq;
  use strict;
  use warnings;
  use Moose::Role;
  
  requires 'equal';
  
  sub no_equal { 
      my ($self, $other) = @_;
      !$self->equal($other);
  }
  
  # ... then in your classes
  
  package Currency;
  use strict;
  use warnings;
  use Moose;
  
  with 'Eq';
  
  sub equal {
      my ($self, $other) = @_;
      $self->as_float == $other->as_float;
  }

DESCRIPTION

This is currently a very early release of Perl 6 style Roles for Moose, it is still incomplete, but getting much closer. If you are interested in helping move this feature along, please come to #moose on irc.perl.org and we can talk.

CAVEATS

Currently, the role support has a few of caveats. They are as follows:

  • At this time classes cannot correctly consume more than one role. The role composition process, and it's conflict detection has not been added yet. While this should be considered a major feature, it can easily be worked around, and in many cases, is not needed at all.

    A class can actually consume multiple roles, they are just applied one after another in the order you ask for them. This is incorrect behavior, the roles should be merged first, and conflicts determined, etc. However, if your roles do not have any conflicts, then things will work just fine. This actually tends to be quite sufficient for basic roles.

  • Roles cannot use the extends keyword, it will throw an exception for now. The same is true of the augment and inner keywords (not sure those really make sense for roles). All other Moose keywords will be deferred so that they can be applied to the consuming class.

BUGS

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.

AUTHOR

Stevan Little <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Copyright 2006 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.