Module: legio/construct

legio/construct

(require("legio/construct"))(data) → {construct}

A function which generates a special constructor using the data argument.
Parameters:
Name Type Description
data config
Source:
Returns:
Type
construct
Example
var A = construct({
  init: function (a) {
    this.a = a;
  },

  proto: {
    toString: function () {
      return "a: " + this.a;
    }
  }
});

var Show = {
  show: function () {
    alert(this.a + ", " + this.b);
  }
};

var B = construct({
  inherit: A,

  init: function (a, b) {
    this.superInit(a);

    this.b = b;
  },

  proto: {
    toString: function () {
      return this.superCall("toString") + ", b: " + this.b;
    }
  },

  mixin: [Show],

  own: {
    create: function (a, b) {
      return new B(a, b);
    }
  }
});
Source:

Type Definitions

config

Properties:
Name Type Attributes Description
init function The constructor function
proto Object <optional>
The prototype of the constructor
inherit constructor <optional>
An inherited constructor
own Object <optional>
An object of static properties
mixin Array.<Object> <optional>
An array of mixins
Source:

construct()

Properties:
Name Type Attributes Description
Super function <optional>
The inherited constructor
superInit function <optional>
A method which calls the inherited constructor with given arguments.
superCall superCall <optional>
A method which calls an inherited method.
Source:

superCall(methodName, argsopt)

Parameters:
Name Type Attributes Description
methodName String
args Array <optional>
Source:

„Nejkrásnější ze všech tajemství je být géniem a vědět to jen sám.“ Mark Twain