Requires

Provides

Class.Refactor.js

Extends a class onto itself with new property, preserving any items attached to the class's namespace.

License:
MIT-style license
Authors:
Aaron Newton
  1. 26
  2. 27
  3. 28
  4. 29
  5. 30
  6. 31
  7. 32
  8. 33
  9. 34
  10. 35
  11. 36
  12. 37
  13. 38
  14. 39
  15. 40
  16. 41
  17. 42
  18. 43
  19. 44
  20. 45
  21. 46
Class.refactor = function(original, refactors){ Object.each(refactors, function(item, name){ var origin = original.prototype[name]; if (origin) origin = origin.$origin; if (origin && typeof item == 'function'){ original.implement(name, function(){ var old = this.previous; this.previous = origin; var value = item.apply(this, arguments); this.previous = old; return value; }); } else { original.implement(name, item); } }); return original; };