mixin. Class extension [3.4.5]


^reflection:mixin[source;options]

Copies fields and methods of a source class into recipient class.

Options hash can be specified:
·$.to[recipient] - to specify the recipient class, into which fields and methods will be copied. Default is the class, from which mixin was called.  
·$.name[name] - to copy only method or field with the specified name. By default all methods and fields are copied.  
·$.methods(true/false) - to specify if source class methods should be copied. Default is to copy.  
·$.fields(true/false) - to specify if source class static fields should be copied. Default is to copy.  
·$.overwrite(false/true) - to specify if methods and fields with same name of the recipient class should be overwritten. Default is not to overwrite.  

Example

@CLASS
B

@auto[]
^reflection:mixin[$A:CLASS; $.fields(false) ]

Copies methods of class A into class B upon class B load.



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 21.03.2017