Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2016-0-4 21:22

Class enchant.Class.MixingRecipe

This class is describing in which way the mixing will be performed on the target classes. For this purpose, MixingRecipe contains three properties:

  • decorateMethods (methods which will be decorated in the target, see decorator pattern)
  • overrideMethods (methods which will be overriden in the target)
  • overrideProperties (properties which will be redefined in the target)

See also enchant.Class.mixClasses, enchant.Class.mixClassesFromRecipe and enchant.Class.applyMixingRecipe.

Class Summary
Constructor Attributes Constructor Name and Description
 
enchant.Class.MixingRecipe(decorateMethods, overrideMethods, properties)
Creates a new MixingRecipe which is used for describing in which way functions and properties should be added during the mixing.
Field Summary
Field Attributes Field Name and Description
 
The methods which will be decorated in the target, see decorator pattern.
 
The methods which will be overriden in the target.
 
The properties which will be redefined in the target.

Method Summary

Method Attributes Method Name and Description
<static>  
enchant.Class.MixingRecipe.createFromClass(sourceClass, boolean, Array, Array, Array)
Takes the methods and properties of the given class to create a new MixingRecipe.

Class Detail

enchant.Class.MixingRecipe(decorateMethods, overrideMethods, properties)
Creates a new MixingRecipe which is used for describing in which way functions and properties should be added during the mixing. To create a recipe from an existing class see enchant.Class.MixingRecipe.createFromClass
     var recipe = new enchant.Class.MixingRecipe({
         add : function(value) {
             this._myValue += 3*value;
             this._mixing.add.apply(this,arguments);
         },
         mult : function(value) {
             this._myValue *= value*7;
             this._mixing.mult.apply(this,arguments);
         }
     },{
         sub : function(value) {
             this._myValue -= 5*value;
         }
     },{
     myProperty : {
         get: function() {
             return 3*this._myPropertyValue;
         },
         set : function(val) {
             this._myPropertyValue = val;
         }
     }});
     var NewClass = enchant.Class.applyMixingRecipe(Class1,recipe);
Parameters:
{Object} decorateMethods
The methods which will be decorated in the target, see decorator pattern. To access methods which have been decorated in the class resulting from mixing the _mixing property can be used, e.g. this._mixing.myFunction.apply(this,arguments).
(Object containing key-value pairs, key := function name, value := function).
{Object} overrideMethods
The methods which will be overriden in the target.
(Object containing key-value pairs, key := function name, value := function).
{Object} properties
The properties which will be redefined in the target.
(Object containing key-value pairs, key := function name, value := property descriptor).

Field Detail

{Object} decorateMethods
The methods which will be decorated in the target, see decorator pattern. To access methods which have been decorated in the class resulting from mixing the _mixing property can be used, e.g. this._mixing.myFunction.apply(this,arguments).
(Object containing key-value pairs, key := function name, value := function).
{Object} overrideMethods
The methods which will be overriden in the target.
(Object containing key-value pairs, key := function name, value := function).
{Object} overrideProperties
The properties which will be redefined in the target.
(Object containing key-value pairs, key := function name, value := property descriptor).

Method Detail

  • <static> {enchant.Class.MixingRecipe} enchant.Class.MixingRecipe.createFromClass(sourceClass, boolean, Array, Array, Array)
    Takes the methods and properties of the given class to create a new MixingRecipe. The default behavior is to take all functions and properties of the given class including functions and properties defined in super classes, whereas functions are set to decorate the mixing target.
    Methods which are decorated will automatically call the soureClass method and the mixing target method (using the _mixing property) - so there is no need to handle this yourself.

    To change the default behavior set the corresponding arguments of the function.

         var recipe = enchant.Class.MixingRecipe.createFromClass(Class2, true, 
                 ['overrideFunction1','overrideFunction2'],
                 ['ignoreFunction1','ignoreFunction2'],
                 ['ignoreProperty1','ignorePropterty2']);
         recipe.overrideMethods['additionalFunction'] = new function() {
             console.log('Hello, World');
         }
         recipe.overrideProperties['newProperty'] = {
             get: function() {
                 return this._newProperty;
             },
             set : function(val) {
                 this._newProperty = val;
             }
         }
         var NewClass = enchant.Class.mixClassesFromRecipe(Class1,Class2,recipe);
    Parameters:
    {Function<constructor function created with enchant.Class>} sourceClass
    The class which will be used to create the recipe.
    boolean Optional
    onlyOwnProperties If set to true, the functions and properties of the super classes will be ignored.
    Array Optional
    functionOverrideNameList An array containing names of functions which should be set to override functions in the target during mixing.
    Array Optional
    functionIgnoreNameList An array containing names of functions which should be ignored when creating the recipe.
    Array Optional
    propertyIgnoreNameList An array containing names of properties which should be ignored when creating the recipe.
    Returns:
    {enchant.Class.MixingRecipe} The MixingRecipe created from the definition of the sourceClass.