| Moose::Meta::Role - The Moose Role metaclass |
Moose::Meta::Role - The Moose Role metaclass
This class is a subclass of the Class::MOP::Module manpage that provides additional Moose-specific functionality.
It's API looks a lot like the Moose::Meta::Class manpage, but internally it implements many things differently. This may change in the future.
Moose::Meta::Role is a subclass of the Class::MOP::Module manpage.
initialize($role_name) >>
This method creates a new role object with the provided name.
This method accepts a list of array references. Each array reference
should contain a role name as its first element. The second element is
an optional hash reference. The hash reference can contain exclude
and alias keys to control how methods are composed from the role.
The return value is a new the Moose::Meta::Role::Composite manpage that represents the combined roles.
This method is identical to the the Moose::Meta::Class manpage create
method.
This method is identical to the the Moose::Meta::Class manpage
create_anon_class method.
Returns true if the role is an anonymous role.
This method applies a role to the given $thing. That can be another
the Moose::Meta::Role manpage, object, a the Moose::Meta::Class manpage object, or a
(non-meta) object instance.
The options are passed directly to the constructor for the appropriate the Moose::Meta::Role::Application manpage subclass.
Note that this will apply the role even if the $thing in question already
does this role. does_role in the Moose::Util manpage is a convenient wrapper for
finding out if role application is necessary.
This returns an array reference of roles which this role does. This list may include duplicates.
This returns a unique list of all roles that this role does, and all the roles that its roles do.
does_role($role_name) >>
Given a role name, returns true if this role does the given role.
add_role($role) >>
Given a the Moose::Meta::Role manpage object, this adds the role to the list of roles that the role does.
Returns a list of role names which this role excludes.
excludes_role($role_name) >>
Given a role name, returns true if this role excludes the named role.
add_excluded_roles(@role_names) >>
Given one or more role names, adds those roles to the list of excluded roles.
The methods for dealing with a role's methods are all identical in API and behavior to the same methods in the Class::MOP::Class manpage.
Returns the method metaclass name for the role. This defaults to the Moose::Meta::Role::Method manpage.
get_method($name) >>
has_method($name) >>
find_method_by_name($name) >>
These methods are all identical to the methods of the same name in the Class::MOP::Class manpage
As with methods, the methods for dealing with a role's attribute are all identical in API and behavior to the same methods in the Class::MOP::Class manpage.
However, attributes stored in this class are not stored as
objects. Rather, the attribute definition is stored as a hash
reference. When a role is composed into a class, this hash reference
is passed directly to the metaclass's add_attribute method.
This is quite likely to change in the future.
get_attribute($attribute_name) >>
has_attribute($attribute_name) >>
remove_attribute($attribute_name) >>
Returns the list of methods required by the role.
requires_method($name) >>
Returns true if the role requires the named method.
add_required_methods(@names) >>
Adds the named methods to the role's list of required methods.
remove_required_methods(@names) >>
Removes the named methods from the role's list of required methods.
add_conflicting_method(%params) >>
Instantiate the parameters as a the Moose::Meta::Role::Method::Conflicting manpage object, then add it to the required method list.
These methods act like their counterparts in the Class::Mop::Class manpage and the Moose::Meta::Class manpage.
However, method modifiers are simply stored internally, and are not applied until the role itself is applied to a class.
These methods all add an appropriate modifier to the internal list of modifiers.
Return true if the role has any modifiers of the given type.
get_after_method_modifiers($method_name) >>
get_around_method_modifiers($method_name) >>
get_before_method_modifiers($method_name) >>
Given a method name, returns a list of the appropriate modifiers for that method.
get_override_method_modifier($method_name) >>
Given a method name, returns the override method modifier for that method, if it has one.
This will return a the Class::MOP::Class manpage instance for this class.
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.
Stevan Little <stevan@iinteractive.com>
Copyright 2006-2009 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Moose::Meta::Role - The Moose Role metaclass |