MooseX::Role::MissingMethodUtils - Getting rid of boilerplate AUTOLOAD stuff
version 0.02
package Foo; use Moose; with 'MooseX::Role::MissingMethodUtils'; sub method_missing { my ($self, $method_name, @params) = @_; if ( $method_name eq 'do_this' ) { Delegator->do_this; } } sub responds_to { my ($self, $method_name) = @_; if ( $method_name =~ /foo/ ) { return sub { print "Bar"; } } }
This role will now introduce a method named method_missing. This method is called via AUTOLOAD as a last resort in the calling chain.
Three parameters will be passed in to help with delegation: ref to self,method name, and parameters.
Call back method that is called during the AUTOLOAD phase. It's unable to find a method and will call this method_missing as last resort for delegation.
Call back method that is called during a "can" call. This method needs to just return a sub ref.
Just does all the boilerplate autoloading stuff. Will call "method_missing"
A subclass of can, will call "responds_to" if nothing is found in super.
Logan Bell <loganbell@gmail.com>
This software is Copyright (c) 2011 by Logan Bell.
This is free software, licensed under:
The (three-clause) BSD License
To install MooseX::Role::MissingMethodUtils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::MissingMethodUtils
CPAN shell
perl -MCPAN -e shell install MooseX::Role::MissingMethodUtils
For more information on module installation, please visit the detailed CPAN module installation guide.