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 CHANGED
@@ -11,7 +11,7 @@ paths:
11
11
  - spec/javascripts/**/*.js
12
12
 
13
13
  exclude_paths:
14
-
14
+ - spec/javascripts/support/vendor/**/*.js
15
15
 
16
16
  # ------------ jshint options ------------
17
17
  # visit http://jshint.com/ for complete documentation
@@ -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(originalParse, response) {
93
- return _(originalParse.call(this, response)).tap(_(function(parsedResponse) {
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(fn) {
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).chain().omit('collection', 'constructor', 'initialize', 'model').reduce(function(proto, fn, name) {
24
- proto[name] = wrapDecorator(fn);
25
- return proto;
26
- }, {}).value();
27
-
28
- return _(Backbone.Model.extend.call(this, _(protoProps).extend(proto), classProps)).tap(function(Klass) {
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);
@@ -91,4 +91,4 @@
91
91
  };
92
92
 
93
93
  Backbone.extensions = _(Backbone.extensions || {}).extend({delegateEvents: delegateEvents});
94
- })(_, Backbone);
94
+ }).call(this, _, Backbone);
@@ -13,4 +13,4 @@
13
13
  };
14
14
 
15
15
  Backbone.extensions = _(Backbone.extensions || {}).extend({include: include});
16
- })(_, Backbone);
16
+ }).call(this, _, Backbone);
@@ -1,3 +1,3 @@
1
1
  module BackboneExtensions
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
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.8
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-07 00:00:00.000000000 Z
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: 786752361875731310
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: 786752361875731310
138
+ hash: -4118179705553602004
139
139
  requirements: []
140
140
  rubyforge_project:
141
141
  rubygems_version: 1.8.24