- targets = _.isArray(mapping.target) ? mapping.target : [mapping.target];
- if(_.contains(existingPropertyNames, methodName)) {
- throw new Error('Cannot extend {target} with method name {methodName}. Name already exists.'
- .replace('{target}', mapping.target)
- .replace('{methodName}', methodName)
- );
- }
- targets.forEach(function(target) {
- if(target === doc) {
- target.registerMethod(methodName, method);
- } else {
- doc.registerNodeMethod(methodName, method);
- }
-
- });
+ operation;
+ operation = {document: 'registerMethod', documentNode: 'registerNodeMethod'}[dstName];
+ doc[operation](methodName, method);
+