backbone_extensions 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/config/jshint.yml +1 -1
- data/lib/assets/javascripts/backbone_extensions/associations.js +3 -3
- data/lib/assets/javascripts/backbone_extensions/decorator.js +13 -10
- data/lib/assets/javascripts/backbone_extensions/delegate_events.js +1 -1
- data/lib/assets/javascripts/backbone_extensions/include.js +1 -1
- data/lib/backbone_extensions/version.rb +1 -1
- metadata +4 -4
data/config/jshint.yml
CHANGED
@@ -89,8 +89,8 @@
|
|
89
89
|
|
90
90
|
if (!this._parsers) {
|
91
91
|
var parsers = this._parsers = [];
|
92
|
-
this.prototype.parse = _(this.prototype.parse).wrap(function(
|
93
|
-
return _(
|
92
|
+
this.prototype.parse = _(this.prototype.parse).wrap(function(oldParse, response) {
|
93
|
+
return _(oldParse.call(this, response)).tap(_(function(parsedResponse) {
|
94
94
|
_(parsers)
|
95
95
|
.chain()
|
96
96
|
.map(function(parser) {
|
@@ -157,4 +157,4 @@
|
|
157
157
|
}
|
158
158
|
|
159
159
|
Backbone.extensions = _(Backbone.extensions || {}).extend({associations: mixin});
|
160
|
-
})(_, Backbone);
|
160
|
+
}).call(this, _, Backbone);
|
@@ -5,27 +5,30 @@
|
|
5
5
|
this.initialize.call(this, models, options);
|
6
6
|
}
|
7
7
|
|
8
|
-
function wrapDecorator(
|
8
|
+
function wrapDecorator(fnName) {
|
9
|
+
var Klass = this;
|
9
10
|
return function() {
|
10
11
|
var args = arguments;
|
11
12
|
if (_(this._decoratee).isArray()) {
|
12
13
|
return _(this._decoratee).map(function(model) {
|
13
|
-
return fn.apply(model, args);
|
14
|
+
return (Klass.fn[fnName]).apply(model, args);
|
14
15
|
});
|
15
16
|
} else {
|
16
|
-
return fn.apply(this._decoratee, args);
|
17
|
+
return (Klass.fn[fnName]).apply(this._decoratee, args);
|
17
18
|
}
|
18
19
|
};
|
19
20
|
}
|
20
21
|
|
21
22
|
_(Decorator).extend({
|
22
23
|
extend: function(protoProps, classProps) {
|
23
|
-
var proto = _(protoProps)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
var proto = _(protoProps)
|
25
|
+
.chain()
|
26
|
+
.omit('collection', 'constructor', 'initialize', 'model'),
|
27
|
+
wrapped = proto.reduce(function(proto, fn, name) {
|
28
|
+
return (proto[name] = wrapDecorator.call(this, name)) && proto;
|
29
|
+
}, {}, this).value();
|
30
|
+
this.fn = proto.value();
|
31
|
+
return _(Backbone.Model.extend.call(this, _(protoProps).extend(wrapped), classProps)).tap(function(Klass) {
|
29
32
|
_(['model', 'collection']).each(function(type) {
|
30
33
|
if (protoProps[type]) {
|
31
34
|
protoProps[type].prototype.decorator = function() {
|
@@ -42,4 +45,4 @@
|
|
42
45
|
});
|
43
46
|
|
44
47
|
Backbone.extensions = _(Backbone.extensions || {}).extend({Decorator: Decorator});
|
45
|
-
})(_, Backbone);
|
48
|
+
}).call(this, _, Backbone);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backbone_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fuubar
|
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
segments:
|
128
128
|
- 0
|
129
|
-
hash:
|
129
|
+
hash: -4118179705553602004
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
none: false
|
132
132
|
requirements:
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
segments:
|
137
137
|
- 0
|
138
|
-
hash:
|
138
|
+
hash: -4118179705553602004
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
141
|
rubygems_version: 1.8.24
|