Wraps another method in the same class.
When a method is invoked using its unqualified name, the runtime...
- Collects all of the active methods and active wrapper methods in the current object which share that unqualified name.
- Arranges all of those methods into a stack.
- Sets up the
@base
abbreviation so that it calls the next method down the stack, or performs a no-op if we're at the bottom of the stack. - Invokes the topmost method in the stack, returning its result.
The wrapper method's name must be the qualified name of the method which is being
wrapped. To wrap the met dance
method in the Joyful
state, write wrap Joyful:dance
in a different state or mixin.
If you replace the name of the state with an underscore, e.g. _:dance
, then this clause
will define a "wildcard wrapper" method. A wildcard wrapper can wrap any method which
shares the same unqualified name. In practice, this means that all of the wildcard methods
are placed on top of the method stack, in an unspecified order.