text: // Generated by CoffeeScript 1.10.0
  (function() {
    var getValue;
  
    module.exports.setupBackboneSync = function(options) {
      var storage;
      if (options == null) {
        options = {};
      }
      if (options instanceof this) {
        storage = options;
      } else {
        storage = new this(options);
      }
      return function(method, object, options) {
        var address, input;
        if (options == null) {
          options = {};
        }
        address = getValue(object, "storageAddress") || getValue(object, "url");
        input = (function() {
          switch (method) {
            case "read":
              return getValue(object, "criteria");
            case "create":
            case "update":
              return object.toJSON();
          }
        })();
        return storage[method](address, input, function(error, output, response, request) {
          if (error === void 0) {
            if (options.success) {
              options.success(object, output, options);
            }
            return object.trigger("sync", object, output, options);
          } else {
            if (options.error) {
              options.error(object, request, options);
            }
            return object.trigger("error", object, request, options);
          }
        });
      };
    };
  
    getValue = function(object, member) {
      var ref;
      if ((ref = object[member]) != null ? ref.call : void 0) {
        return object[member]();
      } else {
        return object[member];
      }
    };
  
  }).call(this);
  