Module: tastypie/lib/class

Prototypal inheritance made easy - A slight modification on the prime libs


new (require("tastypie/lib/class"))(prototype)

Parameters:
Name Type Description
prototype Object

an object to serve as the instance prototype

Properties
Name Type Argument Description
constructor function <optional>
mixin Class | Array.<Class> | function | Array.<function()> <optional>
extends function | Class <optional>

A function or class definintion to server as the prototype to inherit from ( parent class )

Source:
Example
var EventEmitter = require('events').EventEmitter
var Options = require('tastypie/lib/class/options');

MyClass = new Class({
    extends: require('fs').Stream
    ,mixin:[ EventEmitter, Options ]
    ,options:{
        isActive: false
    }
    ,constructor: function( options ){
        this.setOptions( options ) // from options mixin
        console.log("im the constructor");
        EventEmitter.call( this );
    }
    ,work: function(){
        console.log('I'm doing work)
        this.emit('work', this.options.isActive )
    }
 });

Requires

  • module:mout/object/hasOwn
  • module:mout/object/mixIn
  • module:mout/lang/createObject
  • module:mout/lang/kindOf
  • module:mout/lang/clone
  • module:mout/object/merge