Moose::Policy::SingleInheritence - Why would you ever need more than one?


Moose-Policy documentation Contained in the Moose-Policy distribution.

Index


Code Index:

NAME

Top

Moose::Policy::SingleInheritence - Why would you ever need more than one?

SYNOPSIS

Top

  package Foo;

  use Moose::Policy 'Moose::Policy::SingleInheritence';
  use Moose;

  package Bar;

  use Moose::Policy 'Moose::Policy::SingleInheritence';
  use Moose;

  package Foo::Bar;

  use Moose::Policy 'Moose::Policy::SingleInheritence';
  use Moose;

  extends 'Foo', 'Bar';  # BOOM!!!!

DEPRECATION NOTICE

Top

Moose::Policy is deprecated.

DESCRIPTION

Top

This module restricts Moose's extends keyword so that you can only assign a single superclass.

This is mostly an example of how you can restrict behavior with meta-policies in addition to extending and/or customising them. However, sometimes enforcing a policy like this can be a good thing.

BUGS

Top

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

Top

Stevan Little <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Top


Moose-Policy documentation Contained in the Moose-Policy distribution.

package Moose::Policy::SingleInheritence;

use constant metaclass => 'Moose::Policy::SingleInheritence::MetaClass';

package Moose::Policy::SingleInheritence::MetaClass;
use Moose;

extends 'Moose::Meta::Class';

before 'superclasses' => sub {
    my ($self, @superclasses) = @_;
    confess 'Moose::Policy::SingleInheritence in effect for ' . 
             $self->name . ', only single inheritence is allowed'
         if scalar @superclasses > 1;
};

1;

__END__