Apply roles to a class related to yours
version 0.004
package My::Class; use Moose; has driver_class => ( isa => 'MyApp::Driver', ); with 'MooseX::RelatedClassRoles' => { name => 'driver' }; # ... my $obj = My::Class->new(driver_class => "Some::Driver"); $obj->apply_driver_class_roles("Other::Driver::Role");
Frequently, you have to use a class that provides some \*(C`foo_class\*(C' accessor or attribute as a method of dependency injection. Use this role when you'd rather apply roles to make your custom \*(C`foo_class\*(C' instead of manually setting up a subclass.
A string naming the related class. \*(C`driver\*(C' in the \*(L"\s-1SYNOPSIS\s0\*(R". Required.
A string naming the related class accessor. \*(C`driver_class\*(C' in the \*(L"\s-1SYNOPSIS\s0\*(R". Defaults to appending \*(C`_class\*(C' to the \*(C`name\*(C'.
A string naming the role applying method. \*(C`apply_driver_class_names\*(C' in the \*(L"\s-1SYNOPSIS\s0\*(R". Defaults to adding \*(C`apply_\*(C' and \*(C`_names\*(C' to the \*(C`class_accessor_name\*(C'.
Florian Ragwitz (rafl)
Hans Dieter Pearcey <[email protected]>
This software is copyright (c) 2009 by Hans Dieter Pearcey <[email protected]>.
This is free software; you can redistribute it and/or modify it under the same terms as perl itself.