An example of extending Moops to add an exception keyword.
exception
MoopsX::TraitFor::Parser::ExceptionKeyword is a trait for Moops::Parser, adding support for parsing the exception keyword, and injects the MoopsX::Keyword::Exception class when it is encountered.
MoopsX::Keyword::Exception is a simple subclass of Moops::Keyword::Class and simply adds Throwable to the list of roles that the class does.
A more practical application of this would be something like an MVC framework, where you might want to define model, view and controller keywords, which set up classes with particular inheritance patterns, and import commonly used functions into each (e.g. URI manipulation functions into controllers, and HTML escaping functions into views).
model
view
controller
Requires the Throwable role which is available from CPAN.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 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.
To install Moops, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Moops
CPAN shell
perl -MCPAN -e shell install Moops
For more information on module installation, please visit the detailed CPAN module installation guide.