Created
January 5, 2011 20:57
-
-
Save perlpilot/766993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handles => ARRAY | HASH | REGEXP | ROLE | ROLETYPE | DUCKTYPE | CODE | |
The handles option provides Moose classes with automated delegation features. | |
This is a pretty complex and powerful option. It accepts many different option | |
formats, each with its own benefits and drawbacks. | |
NOTE: The class being delegated to does not need to be a Moose based class, which | |
is why this feature is especially useful when wrapping non-Moose classes. | |
All handles option formats share the following traits: | |
You cannot override a locally defined method with a delegated method; an exception | |
will be thrown if you try. That is to say, if you define "foo" in your class, you | |
cannot override it with a delegated "foo". This is almost never something you | |
would want to do, and if it is, you should do it by hand and not use Moose. | |
You cannot override any of the methods found in Moose::Object, or the "BUILD" and | |
"DEMOLISH" methods. These will not throw an exception, but will silently move on | |
to the next method in the list. My reasoning for this is that you would almost | |
never want to do this, since it usually breaks your class. As with overriding | |
locally defined methods, if you do want to do this, you should do it manually, not | |
with Moose. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment