Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

moosex::role::parameterized::extending(3) [osx man page]

MooseX::Role::Parameterized::Extending(3)		User Contributed Perl Documentation		 MooseX::Role::Parameterized::Extending(3)

MooseX::Role::Parameterized::Extending - extending MooseX::Role::Parameterized roles DESCRIPTION
There are heaps of useful modules in the "MooseX" namespace that you can use to make your roles more powerful. However, they do not always work out of the box with MooseX::Role::Parameterized, but it's fairly straight-forward to achieve the functionality you desire. MooseX::Role::Parameterized was designed to be as extensible as the rest of Moose, and as such it is possible to apply custom traits to both the parameterizable role or the ordinary roles they generate. In this example, we will look at applying the fake trait "MooseX::MagicRole" to a parameterizable role. First we need to define a new metaclass for our parameterizable role. package MyApp::Meta::Role::Parameterizable; use Moose; extends 'MooseX::Role::Parameterized::Meta::Role::Parameterizable'; with 'MooseX::MagicRole'; This is a class (observe that it uses Moose, not Moose::Role) which extends the class which governs parameterizable roles. MooseX::Role::Parameterized::Meta::Role::Parameterizable is the metaclass that packages using MooseX::Role::Parameterized receive by default. Note that the class we are extending, MooseX::Role::Parameterized::Meta::Role::Parameterizable, is entirely distinct from the similarly- named class which governs the ordinary roles that parameterized roles generate. An instance of MooseX::Role::Parameterized::Meta::Role::Parameterized represents a role with its parameters already bound. Now we can take advantage of our new subclass by specifying that we want to use "MyApp::Meta::Role::Parameterizable" as our metaclass when importing MooseX::Role::Parameterized: package MyApp::Role; use MooseX::Role::Parameterized -metaclass => 'MyApp::Meta::Role::Parameterizable'; role { ... } And there you go! "MyApp::Role" now has the "MooseX::MagicRole" trait applied. perl v5.16.2 2010-12-24 MooseX::Role::Parameterized::Extending(3)

Check Out this Related Man Page

MooseX::Role::Parameterized::Meta::Role::ParameterizableUser Contributed Perl DocumentaMooseX::Role::Parameterized::Meta::Role::Parameterizable(3)

MooseX::Role::Parameterized::Meta::Role::Parameterizable - metaclass for parameterizable roles DESCRIPTION
This is the metaclass for parameterizable roles, roles that have their parameters currently unbound. These are the roles that you use "with" in Moose, but instead of composing the parameterizable role, we construct a new parameterized role (MooseX::Role::Parameterized::Meta::Role::Parameterized) and use that new parameterized instead. ATTRIBUTES
parameterized_role_metaclass The name of the class that will be used to construct the parameterized role. parameters_class The name of the class that will be used to construct the parameters object. parameters_metaclass A metaclass representing this roles's parameters. It will be an anonymous subclass of "parameters_class". Each call to "parameter" in MooseX::Role::Parameters adds an attribute to this metaclass. When this role is consumed, the parameters object will be instantiated using this metaclass. role_generator A code reference that is used to generate a role based on the parameters provided by the consumer. The user usually specifies it using the "role" in MooseX::Role::Parameterized keyword. METHODS
add_parameter $name, %options Delegates to "add_attribute" in Moose::Meta::Class on the "parameters_metaclass" object. construct_parameters %arguments Creates a new MooseX::Role::Parameterized::Parameters object using metaclass "parameters_metaclass". The arguments are those specified by the consumer as parameter values. generate_role %arguments This method generates and returns a new instance of "parameterized_role_metaclass". It can take any combination of three named parameters: arguments A hashref of parameters for the role, same as would be passed in at a "with" statement. package A package name that, if present, we will use for the generated role; if not, we generate an anonymous role. consumer A consumer metaobject, if available. apply Overrides "apply" in Moose::Meta::Role to automatically generate the parameterized role. perl v5.16.2 2012-01-12 MooseX::Role::Parameterized::Meta::Role::Parameterizable(3)
Man Page

Featured Tech Videos