|
NAMEObject::Role - base class for non-Moose rolesSYNOPSIS{ package Object::Dumpable; use base qw/Object::Role/; use Data::Dumper; sub import { my ($class, @args) = @_; my ($caller, %args) = __PACKAGE__->parse_arguments(undef, @args); my $coderef = sub { my ($self) = @_; return Dumper($self); }; __PACKAGE__->install_method(dump => $coderef, $caller); } } { package Foo; use Object::Dumpable; sub new { ... } } { package main; my $foo = Foo->new; warn $foo->dump; } DESCRIPTIONThis will be better documented once I fully understand it myself!The idea of this is to be a base class for roles like Object::DOES, Object::Stash and Object::ID. It handles parsing of import arguments, installing methods into the caller's namespace (like Exporter, but using a technique that is immune to namespace::autoclean) and tracking which packages have consumed your role. While "Object::Role" is a base class for roles, it is not itself a role, so does not export anything. Instead, your role must inherit from it. Methods
BUGSPlease report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Object-Role>.SEE ALSOObject::DOES, Object::AUTHORITY.AUTHORToby Inkster <tobyink@cpan.org>.COPYRIGHT AND LICENCEThis software is copyright (c) 2011 by Toby Inkster.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. DISCLAIMER OF WARRANTIESTHIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Visit the GSP FreeBSD Man Page Interface. |