MooseX::Traits::Pluggable - an extension to MooseX::Traits
See MooseX::Traits for usage information.
Adds support for class precedence search for traits and some extra attributes, described below.
If the value of "_trait_namespace" in MooseX::Traits starts with a + the namespace will be considered relative to the class_precedence_list (ie. @ISA) of the original class.
+
class_precedence_list
@ISA
Example:
package Class1 use Moose; package Class1::Trait::Foo; use Moose::Role; has 'bar' => ( is => 'ro', isa => 'Str', required => 1, ); package Class2; use parent 'Class1'; with 'MooseX::Traits'; has '+_trait_namespace' => (default => '+Trait'); package Class2::Trait::Bar; use Moose::Role; has 'baz' => ( is => 'ro', isa => 'Str', required => 1, ); package main; my $instance = Class2->new_with_traits( traits => ['Foo', 'Bar'], bar => 'baz', baz => 'quux', ); $instance->does('Class1::Trait::Foo'); # true $instance->does('Class2::Trait::Bar'); # true
When traits are applied to your class or instance, you get an anonymous class back whose name will be not the same as your original class. So ref $self will not be Class, but $self->_original_class_name will be.
ref $self
Class
$self->_original_class_name
List of the (unresolved) traits applied to the instance.
List of traits applied to the instance resolved to full package names.
Rafael Kitover <rkitover@cpan.org>
<rkitover@cpan.org>
Don't email these guys, they had nothing to do with this fork:
Jonathan Rockway <jrockway@cpan.org>
<jrockway@cpan.org>
Stevan Little <stevan.little@iinteractive.com>
<stevan.little@iinteractive.com>
Copyright 2008 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.
To install MooseX::Traits::Pluggable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Traits::Pluggable
CPAN shell
perl -MCPAN -e shell install MooseX::Traits::Pluggable
For more information on module installation, please visit the detailed CPAN module installation guide.