forked from jashkenas/backbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.js
39 lines (29 loc) · 807 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
(function() {
var Environment = this.Environment = function(){};
_.extend(Environment.prototype, {
ajax: Backbone.ajax,
sync: Backbone.sync,
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;
}
});
})();