Creating a dynamic object is as simple as calling the DynamicObject
function:
let foo = DynamicObject()
Dynamic objects have the following reserved methods, that is, methods that you cannot override:
define(name, value)
allows to define an object property, which can be either a value or a
closure, and
get(name)
gives the value or closure for a property name, or null
if there is none, and
undefine(name)
removes a property from the object, and
mixin(dynobj)
mixes in all the properties of the dynamic object dynobj
, and
copy()
gives a copy of a dynamic object, and
freeze()
locks an object, and calling define
will raise an IllegalStateException
, and
isFrozen()
checks whether a dynamic object is frozen or not, and
properties()
gives the set of entries in the dynamic object, and
hasMethod(name)
checks if a method is defined or not in the dynamic object, and
invoker(name, type)
which is mostly used by the Golo runtime internals, and
fallback(handler)
defines a fallback behavior for property invocation.