- var methods = instance.document.classMethods[klass] || instance.document.classTransformations;
- if(methods) {
- instance.object = Object.create(_.extend({
- transform: function(name, args) {
- // TODO: refactor with DocumentElement.transform
- var Transformation = instance.document.classTransformations[klass].get(name),
- transformation;
- if(Transformation) {
- transformation = new Transformation(instance.document, instance, args);
- }
- return instance.document.transform(transformation);
- }
- }, methods));
- _.keys(methods).forEach(function(key) {
- instance.object[key] = _.bind(instance.object[key], instance);
- });
- }
-}
+ var methods = instance.document.classMethods[klass] || {},
+ transformations = instance.document.classTransformations[klass] || {};
+
+ instance.object = Object.create(_.extend({}, methods, transformations));
+ _.keys(methods).concat(_.keys(transformations)).forEach(function(key) {
+ instance.object[key] = _.bind(instance.object[key], instance);
+ });
+};