method add_fallback
1 | class Metamodel::ClassHOW |
1.1 | (Metamodel::ClassHOW) method add_fallback |
Documentation for method add_fallback
assembled from the following types:
class Metamodel::ClassHOW
From Metamodel::ClassHOW
(Metamodel::ClassHOW) method add_fallback
method add_fallback(Metamodel::ClassHOW: , , )
Installs a method fallback, that is, add a way to call methods that weren't statically added.
Both $condition
and $calculator
must be callables that receive the invocant and the method name once a method is called that can't be found in the method cache.
If $condition
returns a true value, $calculator
is called with the same arguments, and must return the code object to be invoked as the method, and is added to the method cache.
If $condition
returns a false value, the next fallback (if any) is tried, and if none matches, an exception of type X::Method::NotFound is thrown.
User-facing code (that is, code not dabbling with metaclasses) should use method FALLBACK
instead.