import Orbit from 'orbit/core';
import Evented from 'orbit/evented';

var Transformable = {
  extend: function(object, actions) {
    if (object._requestable === undefined) {
      this._requestable = true;

      Evented.extend(object);

      object.didTransform = function(diff, result) {
        return object.settle.call(object, 'didTransform', diff, result);
      };

      object.transform = function(diff) {
        Orbit.assert('_transform must be defined', object._transform);

        return object._transform.call(object, diff).then(
          function(result) {
            return object.didTransform.call(object, diff, result).then(
              function() {
                return result;
              }
            );
          },
          function(error) {
            return object.settle.call(object, 'didNotTransform', diff, error).then(
              function() {
                throw error;
              }
            );
          }
        );
      };
    }
    return object;
  }
};

export default Transformable;
@@ -269,20 +269,25 @@
 unction(
-diff
+operation
 , result
@@ -348,20 +348,25 @@
 sform', 
-diff
+operation
 , result
@@ -412,20 +412,25 @@
 unction(
-diff
+operation
 ) %7B%0A    
@@ -543,20 +543,25 @@
 object, 
-diff
+operation
 ).then(%0A
@@ -641,20 +641,25 @@
 object, 
-diff
+operation
 , result
@@ -865,12 +865,17 @@
 m', 
-diff
+operation
 , er

Rename `diff` -> `operation`