Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

moosex::classattribute::trait::class5.18(3) [mojave man page]

MooseX::ClassAttribute::Trait::Class(3) 		User Contributed Perl Documentation		   MooseX::ClassAttribute::Trait::Class(3)

NAME
MooseX::ClassAttribute::Trait::Class - A trait for classes with class attributes VERSION
version 0.27 SYNOPSIS
for my $attr ( HasClassAttributes->meta()->get_all_class_attributes() ) { print $attr->name(); } DESCRIPTION
This role adds awareness of class attributes to a metaclass object. It provides a set of introspection methods that largely parallel the existing attribute methods, except they operate on class attributes. METHODS
Every method provided by this role has an analogous method in "Class::MOP::Class" or "Moose::Meta::Class" for regular attributes. $meta->has_class_attribute($name) $meta->get_class_attribute($name) $meta->get_class_attribute_list() These methods operate on the current metaclass only. $meta->add_class_attribute(...) This accepts the same options as the Moose::Meta::Attribute "add_attribute()" method. However, if an attribute is specified as "required" an error will be thrown. $meta->remove_class_attribute($name) If the named class attribute exists, it is removed from the class, along with its accessor methods. $meta->get_all_class_attributes() This method returns a list of attribute objects for the class and all its parent classes. $meta->find_class_attribute_by_name($name) This method looks at the class and all its parent classes for the named class attribute. $meta->get_class_attribute_value($name) $meta->set_class_attribute_value($name, $value) $meta->set_class_attribute_value($name) $meta->clear_class_attribute_value($name) These methods operate on the storage for class attribute values, which is attached to the metaclass object. There's really no good reason for you to call these methods unless you're doing some deep hacking. They are named as public methods solely because they are used by other meta roles and classes in this distribution. BUGS
See MooseX::ClassAttribute for details. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) perl v5.18.2 2013-03-28 MooseX::ClassAttribute::Trait::Class(3)

Check Out this Related Man Page

Moose::Cookbook::Meta::Recipe5(3)			User Contributed Perl Documentation			 Moose::Cookbook::Meta::Recipe5(3)

NAME
Moose::Cookbook::Meta::Recipe5 - The "table" attribute as a metaclass trait VERSION
version 2.0205 SYNOPSIS
package MyApp::Meta::Class::Trait::HasTable; use Moose::Role; has table => ( is => 'rw', isa => 'Str', ); package Moose::Meta::Class::Custom::Trait::HasTable; sub register_implementation { 'MyApp::Meta::Class::Trait::HasTable' } package MyApp::User; use Moose -traits => 'HasTable'; __PACKAGE__->meta->table('User'); DESCRIPTION
This recipe takes the metaclass table attribute from Moose::Cookbook::Meta::Recipe4 and implements it as a metaclass trait. Traits are just roles, as we saw in Moose::Cookbook::Meta::Recipe3. The advantage of using traits is that it's easy to combine multiple traits, whereas combining multiple metaclass subclasses requires creating yet another subclass. With traits, Moose takes care of applying them to your metaclass. Using this Metaclass Trait in Practice Once this trait has been applied to a metaclass, it looks exactly like the example we saw in Moose::Cookbook::Meta::Recipe4: my $table = MyApp::User->meta->table; # the safe version $table = MyApp::User->meta->table if MyApp::User->meta->meta->can('does') and MyApp::User->meta->meta->does('MyApp::Meta::Class'); The safe version is a little complicated. We have to check that the metaclass object's metaclass has a "does" method, in which case we can ask if the the metaclass does a given role. It's simpler to just write: $table = MyApp::User->meta->table if MyApp::User->meta->can('table'); In theory, this is a little less correct, since the metaclass might be getting its "table" method from a different role. In practice, you are unlikely to encounter this sort of problem. SEE ALSO
Moose::Cookbook::Meta::Recipe3 - Labels implemented via attribute traits Moose::Cookbook::Meta::Recipe4 - Adding a "table" attribute to the metaclass AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.12.5 2011-09-06 Moose::Cookbook::Meta::Recipe5(3)
Man Page