angularjs-rails-resource 1.2.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e4a5ba390211f28af5390dfedb8b0e74a3f57b3
4
- data.tar.gz: 9b730394170c778a38f7101b03e76b599dc4e9c6
3
+ metadata.gz: 5dcbb9f729e55fc427ad6eaed8e5356f08315d30
4
+ data.tar.gz: 19cfc254499c9fe89f5db0bf93576055d2309f89
5
5
  SHA512:
6
- metadata.gz: 0a699355c35b80febbb396c0908597ccc2426bc340b6396d60638f70ad9aa54e19e243897d5eb829d5909be57c6a8f6ec1e4e4748f5ec38cae963c414f0e1cef
7
- data.tar.gz: fcb9f1ecae719beb565e67c85d5dbaf13cb01cf166efa4386d771e287077ca100af3f3a36d30ba615e89557caa61075ff267e2a5c1da377430085649d240f44b
6
+ metadata.gz: 06c9d9ea3be0fbfea6a3bee07b7a85a08623a3d4d394f0ccee79597d65eb4cd9f0f723d8ac53260e4102767d6597da2d6fcf71a900af256650fe23dc0c7e8ac7
7
+ data.tar.gz: 008723eb726c8aa86aa84ccc15468ef7a6ee223a05ff16fec7c75dc53bf0dbbbf3900a059d28df60ca2afa7f3fd88f6bf13f365a6f52a79b423d92496e5171df
@@ -1,3 +1,8 @@
1
+ <a name="2.0.0"></a>
2
+ # 2.0.0
3
+ ## Breaking Changes
4
+ - Renamed <code>Serializer.serializeValue</code> to <code>Serializer.serializeData</code> and added new <code>Serializer.serializeObject</code> method. - #149 (@andrey-abramow)
5
+
1
6
  <a name="1.2.3"></a>
2
7
  # 1.2.3
3
8
  ## Bug Fixes
data/README.md CHANGED
@@ -35,7 +35,7 @@ angular.module('app').config(["railsSerializerProvider", function(railsSerialize
35
35
  ### Rails Asset Pipeline
36
36
  Add this line to your application's Gemfile to use the latest stable version:
37
37
  ```ruby
38
- gem 'angularjs-rails-resource', '~> 1.2.3'
38
+ gem 'angularjs-rails-resource', '~> 2.0.0'
39
39
  ```
40
40
 
41
41
  Include the javascript somewhere in your asset pipeline:
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angularjs-rails-resource",
3
- "version": "1.2.3",
3
+ "version": "2.0.0",
4
4
  "main": "angularjs-rails-resource.js",
5
5
  "description": "A resource factory inspired by $resource from AngularJS",
6
6
  "repository": {
@@ -25,4 +25,4 @@
25
25
  ".travis.yml",
26
26
  ".gitignore"
27
27
  ]
28
- }
28
+ }
@@ -1,7 +1,7 @@
1
1
  module Angularjs
2
2
  module Rails
3
3
  module Resource
4
- VERSION = '1.2.3'
4
+ VERSION = '2.0.0'
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "angularjs-rails-resource",
3
3
  "description" : "A resource factory inspired by $resource from AngularJS",
4
- "version": "1.2.3",
4
+ "version": "2.0.0",
5
5
  "main" : "dist/angularjs-rails-resource.min.js",
6
6
  "homepage" : "https://github.com/FineLinePrototyping/angularjs-rails-resource.git",
7
7
  "author" : "",
@@ -353,7 +353,7 @@
353
353
  * @param data The data to prepare
354
354
  * @returns {*} A new object or array that is ready for JSON serialization
355
355
  */
356
- Serializer.prototype.serializeValue = function (data) {
356
+ Serializer.prototype.serializeData = function (data) {
357
357
  var result = data,
358
358
  self = this;
359
359
 
@@ -361,7 +361,7 @@
361
361
  result = [];
362
362
 
363
363
  angular.forEach(data, function (value) {
364
- result.push(self.serializeValue(value));
364
+ result.push(self.serializeData(value));
365
365
  });
366
366
  } else if (angular.isObject(data)) {
367
367
  if (angular.isDate(data)) {
@@ -369,17 +369,26 @@
369
369
  }
370
370
  result = {};
371
371
 
372
- angular.forEach(data, function (value, key) {
373
- // if the value is a function then it can't be serialized to JSON so we'll just skip it
374
- if (!angular.isFunction(value)) {
375
- self.serializeAttribute(result, key, value);
376
- }
377
- });
372
+ this.serializeObject(result, data);
373
+
378
374
  }
379
375
 
380
376
  return result;
381
377
  };
382
378
 
379
+ Serializer.prototype.serializeObject = function(result, data){
380
+
381
+
382
+ var tthis = this;
383
+ angular.forEach(data, function (value, key) {
384
+ // if the value is a function then it can't be serialized to JSON so we'll just skip it
385
+ if (!angular.isFunction(value)) {
386
+ tthis.serializeAttribute(result, key, value);
387
+ }
388
+ });
389
+ return data;
390
+ };
391
+
383
392
  /**
384
393
  * Transforms an attribute and its value and stores it on the parent data object. The attribute will be
385
394
  * renamed as needed and the value itself will be serialized as well.
@@ -397,7 +406,7 @@
397
406
  return;
398
407
  }
399
408
 
400
- data[serializedAttributeName] = serializer ? serializer.serialize(value) : this.serializeValue(value);
409
+ data[serializedAttributeName] = serializer ? serializer.serialize(value) : this.serializeData(value);
401
410
  };
402
411
 
403
412
  /**
@@ -435,7 +444,7 @@
435
444
  });
436
445
  }
437
446
 
438
- result = this.serializeValue(result);
447
+ result = this.serializeData(result);
439
448
 
440
449
  return result;
441
450
  };
@@ -447,7 +456,7 @@
447
456
  * @param Resource (optional) The resource type to deserialize the result into
448
457
  * @returns {*} A new object or an instance of Resource populated with deserialized data.
449
458
  */
450
- Serializer.prototype.deserializeValue = function (data, Resource) {
459
+ Serializer.prototype.deserializeData = function (data, Resource) {
451
460
  var result = data,
452
461
  self = this;
453
462
 
@@ -455,27 +464,35 @@
455
464
  result = [];
456
465
 
457
466
  angular.forEach(data, function (value) {
458
- result.push(self.deserializeValue(value, Resource));
467
+ result.push(self.deserializeData(value, Resource));
459
468
  });
460
469
  } else if (angular.isObject(data)) {
461
470
  if (angular.isDate(data)) {
462
471
  return data;
463
472
  }
464
-
465
473
  result = {};
466
474
 
467
475
  if (Resource) {
468
476
  result = new Resource.config.resourceConstructor();
469
477
  }
470
478
 
471
- angular.forEach(data, function (value, key) {
472
- self.deserializeAttribute(result, key, value);
473
- });
479
+ this.deserializeObject(result, data);
480
+
474
481
  }
475
482
 
476
483
  return result;
477
484
  };
478
485
 
486
+ Serializer.prototype.deserializeObject = function (result, data) {
487
+
488
+ var tthis = this;
489
+ angular.forEach(data, function (value, key) {
490
+ tthis.deserializeAttribute(result, key, value);
491
+ });
492
+ return data;
493
+ };
494
+
495
+
479
496
  /**
480
497
  * Transforms an attribute and its value and stores it on the parent data object. The attribute will be
481
498
  * renamed as needed and the value itself will be deserialized as well.
@@ -501,7 +518,7 @@
501
518
  if (this.preservedAttributes[attributeName]) {
502
519
  data[attributeName] = value;
503
520
  } else {
504
- data[attributeName] = serializer ? serializer.deserialize(value, NestedResource) : this.deserializeValue(value, NestedResource);
521
+ data[attributeName] = serializer ? serializer.deserialize(value, NestedResource) : this.deserializeData(value, NestedResource);
505
522
  }
506
523
  };
507
524
 
@@ -518,7 +535,7 @@
518
535
  */
519
536
  Serializer.prototype.deserialize = function (data, Resource) {
520
537
  // just calls deserializeValue for now so we can more easily add on custom attribute logic for deserialize too
521
- return this.deserializeValue(data, Resource);
538
+ return this.deserializeData(data, Resource);
522
539
  };
523
540
 
524
541
  Serializer.prototype.pluralize = function (value) {
@@ -549,4 +566,4 @@
549
566
  return railsSerializer;
550
567
  }];
551
568
  });
552
- }());
569
+ }());
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angularjs-rails-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Odom
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-09 00:00:00.000000000 Z
12
+ date: 2015-02-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A small AngularJS add-on for integrating with Rails via JSON more easily.
15
15
  email: