Method DataObject():defineMethod() Foundation

Defines a dynamic method.

Syntax
:defineMethod( <cMessage>, <cFunction>|<bExpression>) --> self
Parameters
<cMessage>
The message name of the method to be defined.
<cFunction>
The name of the function to be executed when the message <cMessage> is sent to the object. The function receives the DataObject as the first parameter.
<bExpression>
A code block to be executed when the message <cMessage> is sent to the object. The code block receives the DataObject as the first parameter.
Return

This method returns the DataObject (self).

Description

:defineMethod() allows to dynamically add new methods to or to re-define existing methods of a DataObject. Once defined, dynamic methods behave like ordinary methods implemented in a static class, and calls to these methods are not routed to :noMethod(). Dynamic methods using a function as the method implementation only have a small performance penalty compared to static methods. The function IsMethod() can be used to test for the existence of a method added via :defineMethod(). In addition, the method :classDescribe() also reflects dynamic methods.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.