Documentation for 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:D: $condition$calculator)

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 meta classes) should use method FALLBACK instead.