- transform: function(transformation, args) {
- console.log('transform');
- var Transformation, toret;
- if(typeof transformation === 'string') {
- Transformation = this.transformations.get(transformation);
- if(Transformation) {
- transformation = new Transformation(this, this, args);
+ registerMethod: function(methodName, method) {
+ registerMethod(methodName, method, this);
+ },
+
+ registerNodeMethod: function(methodName, method) {
+ registerMethod(methodName, method, this._nodeMethods);
+ },
+
+ registerDocumentTransformation: function(desc, name) {
+ registerTransformation(desc, name, this);
+ },
+
+ registerNodeTransformation: function(desc, name) {
+ registerTransformation(desc, name, this._nodeTransformations);
+ },
+
+ registerExtension: function(extension) {
+ //debugger;
+ var doc = this,
+ existingPropertyNames = _.values(this);
+
+ ['document', 'documentNode'].forEach(function(dstName) {
+ var dstExtension = extension[dstName];
+ if(dstExtension) {
+ if(dstExtension.methods) {
+ _.pairs(dstExtension.methods).forEach(function(pair) {
+ var methodName = pair[0],
+ method = pair[1],
+ operation;
+ operation = {document: 'registerMethod', documentNode: 'registerNodeMethod'}[dstName];
+ doc[operation](methodName, method);
+
+ });
+ }
+
+ if(dstExtension.transformations) {
+ _.pairs(dstExtension.transformations).forEach(function(pair) {
+ var name = pair[0],
+ desc = pair[1],
+ operation;
+ operation = {document: 'registerDocumentTransformation', documentNode: 'registerNodeTransformation'}[dstName];
+ doc[operation](desc, name);
+ });
+ }