UNPKG

factory-granny

Version:

Factory for building flexible JavaScript objects. Inspired by factory_girl.

17 lines (11 loc) 345 B
var merge = require('merge') var copy = merge.bind(merge, true) var fn = function (FactoryGranny) { FactoryGranny.prototype.trait = function (name) { this.traits[name] = new this.constructor() this.traits[name].extend(this) this.traits[name]._static = copy(this._static) return this.traits[name] } } module.exports = fn