Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

class::trait::config(3pm) [debian man page]

Class::Trait::Config(3pm)				User Contributed Perl Documentation				 Class::Trait::Config(3pm)

NAME
Class::Trait::Config - Trait configuration information storage package. SYNOPSIS
This package is used internally by Class::Trait to store Trait configuration information. It is also used by Class::Trait::Reflection to gather information about a Trait. DESCRIPTION
This class is a intentionally very C-struct-like. It is meant to help encapsulate the Trait configuration information in a clean easy to access way. This class is effectively sealed. It is not meant to be extended, only to be used. METHODS
new Creates a new empty Class::Trait::Config object, with fields initialized to empty containers. name An accessor to the "name" string field of the Class::Trait::Config object. sub_traits An accessor to the "sub_traits" array reference field of the Class::Trait::Config object. requirements An accessor to the "requirements" hash reference field of the Class::Trait::Config object. Note, the requirements field is a hash reference to speed requirement lookup, the values of the hash are simply booleans. methods An accessor to the "methods" hash reference field of the Class::Trait::Config object. overloads An accessor to the "overloads" hash reference field of the Class::Trait::Config object. conflicts An accessor to the "conflicts" hash reference field of the Class::Trait::Config object. Note, the conflicts field is a hash reference to speed conflict lookup, the values of the hash are simply booleans. clone Provides deep copy functionality for the Class::Trait::Config object. This will be sure to copy all sub-elements of the object, but not to attempt to copy and subroutine references found. SEE ALSO
Class::Trait, Class::Trait::Reflection AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
Copyright 2004, 2005 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. perl v5.10.0 2010-04-25 Class::Trait::Config(3pm)

Check Out this Related Man Page

MooseX::Traits(3)					User Contributed Perl Documentation					 MooseX::Traits(3)

NAME
MooseX::Traits - automatically apply roles at object creation time SYNOPSIS
Given some roles: package Role; use Moose::Role; has foo => ( is => 'ro', isa => 'Int' required => 1 ); And a class: package Class; use Moose; with 'MooseX::Traits'; Apply the roles to the class at "new" time: my $class = Class->with_traits('Role')->new( foo => 42 ); Then use your customized class: $class->isa('Class'); # true $class->does('Role'); # true $class->foo; # 42 DESCRIPTION
Often you want to create components that can be added to a class arbitrarily. This module makes it easy for the end user to use these components. Instead of requiring the user to create a named class with the desired roles applied, or apply roles to the instance one-by- one, he can just create a new class from yours with "with_traits", and then instantiate that. There is also "new_with_traits", which exists for compatibility reasons. It accepts a "traits" parameter, creates a new class with those traits, and then insantiates it. Class->new_with_traits( traits => [qw/Foo Bar/], foo => 42, bar => 1 ) returns exactly the same object as Class->with_traits(qw/Foo Bar/)->new( foo => 42, bar => 1 ) would. But you can also store the result of "with_traits", and call other methods: my $c = Class->with_traits(qw/Foo Bar/); $c->new( foo => 42 ); $c->whatever( foo => 1234 ); And so on. METHODS
$class->with_traits( @traits ) Return a new class with the traits applied. Use like: $class->new_with_traits(%args, traits => @traits) "new_with_traits" can also take a hashref, e.g.: my $instance = $class->new_with_traits({ traits => @traits, foo => 'bar' }); ATTRIBUTES YOUR CLASS GETS
This role will add the following attributes to the consuming class. _trait_namespace You can override the value of this attribute with "default" to automatically prepend a namespace to the supplied traits. (This can be overridden by prefixing the trait name with "+".) Example: package Another::Trait; use Moose::Role; has 'bar' => ( is => 'ro', isa => 'Str', required => 1, ); package Another::Class; use Moose; with 'MooseX::Traits'; has '+_trait_namespace' => ( default => 'Another' ); my $instance = Another::Class->new_with_traits( traits => ['Trait'], # "Another::Trait", not "Trait" bar => 'bar', ); $instance->does('Trait') # false $instance->does('Another::Trait') # true my $instance2 = Another::Class->new_with_traits( traits => ['+Trait'], # "Trait", not "Another::Trait" ); $instance2->does('Trait') # true $instance2->does('Another::Trait') # false AUTHORS and CONTRIBUTORS Jonathan Rockway "<jrockway@cpan.org>" Stevan Little "<stevan.little@iinteractive.com>" Tomas Doran "<bobtfish@bobtfish.net>" Matt S. Trout "<mst@shadowcatsystems.co.uk>" Jesse Luehrs "<doy at tozt dot net>" Shawn Moore "<sartak@bestpractical.com>" Florian Ragwitz "<rafl@debian.org>" Chris Prather "<chris@prather.org>" Yuval Kogman "<nothingmuch@woobling.org>" COPYRIGHT AND LICENSE
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. perl v5.16.2 2010-05-13 MooseX::Traits(3)
Man Page