forked from jashkenas/backbone
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenvironment.js
45 lines (33 loc) · 981 Bytes
/
environment.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(function() {
var Environment = this.Environment = function(){};
_.extend(Environment.prototype, {
ajax: Backbone.ajax,
sync: Backbone.sync,
emulateHTTP: Backbone.emulateHTTP,
emulateJSON: Backbone.emulateJSON,
setup: function() {
var env = this;
// Capture ajax settings for comparison.
Backbone.ajax = function(settings) {
env.ajaxSettings = settings;
};
// Capture the arguments to Backbone.sync for comparison.
Backbone.sync = function(method, model, options) {
env.syncArgs = {
method: method,
model: model,
options: options
};
env.sync.apply(this, arguments);
};
},
teardown: function() {
this.syncArgs = null;
this.ajaxSettings = null;
Backbone.sync = this.sync;
Backbone.ajax = this.ajax;
Backbone.emulateHTTP = this.emulateHTTP;
Backbone.emulateJSON = this.emulateJSON;
}
});
})();