angularjs-rails-resource 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +1 -1
- data/bower.json +1 -1
- data/lib/angularjs-rails-resource/version.rb +1 -1
- data/package.json +1 -1
- data/test/unit/angularjs/rails/serializationSpec.js +62 -0
- data/vendor/assets/javascripts/angularjs/rails/resource/serialization.js +3 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e4a5ba390211f28af5390dfedb8b0e74a3f57b3
|
4
|
+
data.tar.gz: 9b730394170c778a38f7101b03e76b599dc4e9c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a699355c35b80febbb396c0908597ccc2426bc340b6396d60638f70ad9aa54e19e243897d5eb829d5909be57c6a8f6ec1e4e4748f5ec38cae963c414f0e1cef
|
7
|
+
data.tar.gz: fcb9f1ecae719beb565e67c85d5dbaf13cb01cf166efa4386d771e287077ca100af3f3a36d30ba615e89557caa61075ff267e2a5c1da377430085649d240f44b
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
<a name="1.2.
|
1
|
+
<a name="1.2.3"></a>
|
2
|
+
# 1.2.3
|
3
|
+
## Bug Fixes
|
4
|
+
- Apply custom serialization attributes before doing full serialization - #148 (@envek)
|
5
|
+
|
6
|
+
<a name="1.2.2"></a>
|
2
7
|
# 1.2.2
|
3
8
|
## Bug Fixes
|
4
9
|
- Add support for adding custom attributes when serializing arrays - #143 (@shuhei)
|
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.
|
38
|
+
gem 'angularjs-rails-resource', '~> 1.2.3'
|
39
39
|
```
|
40
40
|
|
41
41
|
Include the javascript somewhere in your asset pipeline:
|
data/bower.json
CHANGED
data/package.json
CHANGED
@@ -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.
|
4
|
+
"version": "1.2.3",
|
5
5
|
"main" : "dist/angularjs-rails-resource.min.js",
|
6
6
|
"homepage" : "https://github.com/FineLinePrototyping/angularjs-rails-resource.git",
|
7
7
|
"author" : "",
|
@@ -453,5 +453,67 @@ describe('railsSerializer', function () {
|
|
453
453
|
expect(result).toEqual({ id: 1, books: [book]});
|
454
454
|
});
|
455
455
|
});
|
456
|
+
|
457
|
+
describe('nested resource collection serialization', function () {
|
458
|
+
module('rails');
|
459
|
+
|
460
|
+
angular.module('rails').factory('Team', function (railsResourceFactory, railsSerializer) {
|
461
|
+
return railsResourceFactory({
|
462
|
+
name: 'team',
|
463
|
+
serializer: railsSerializer(function() {
|
464
|
+
this.nestedAttribute('members');
|
465
|
+
this.resource('members', 'Member');
|
466
|
+
this.add('vehicle_id', function(team) {
|
467
|
+
return team.vehicle.id;
|
468
|
+
});
|
469
|
+
this.exclude('vehicle');
|
470
|
+
})
|
471
|
+
});
|
472
|
+
});
|
473
|
+
angular.module('rails').factory('Member', function (railsResourceFactory, railsSerializer) {
|
474
|
+
return railsResourceFactory({
|
475
|
+
name: 'member',
|
476
|
+
serializer: railsSerializer(function() {
|
477
|
+
this.resource('user', 'User');
|
478
|
+
this.resource('slot', 'Slot');
|
479
|
+
this.add('user_id', function(member) {
|
480
|
+
return member.user.id;
|
481
|
+
});
|
482
|
+
this.add('slot_id', function(member) {
|
483
|
+
return member.slot.id;
|
484
|
+
});
|
485
|
+
this.exclude('user', 'slot');
|
486
|
+
})
|
487
|
+
});
|
488
|
+
});
|
489
|
+
angular.module('rails').factory('Slot', function (railsResourceFactory) {
|
490
|
+
return railsResourceFactory({name: 'slot'});
|
491
|
+
});
|
492
|
+
angular.module('rails').factory('User', function (railsResourceFactory) {
|
493
|
+
return railsResourceFactory({name: 'user'});
|
494
|
+
});
|
495
|
+
angular.module('rails').factory('Vehicle', function (railsResourceFactory) {
|
496
|
+
return railsResourceFactory({name: 'vehicle'});
|
497
|
+
});
|
498
|
+
|
499
|
+
|
500
|
+
it('should add custom attribute in nested resource', inject(function(Team) {
|
501
|
+
var team1 = new Team({
|
502
|
+
id: 1,
|
503
|
+
name: 'Team 1',
|
504
|
+
vehicle: { id: 123, name: 'Subaru Impreza' },
|
505
|
+
members: [
|
506
|
+
{ id: 352435, user: { id: 100500, name: 'Andrey' }, slot: { id: 200425, rank_id: 1 } },
|
507
|
+
{ id: 235433, user: { id: 100501, name: 'Anton' }, slot: { id: 200426, rank_id: 2 } },
|
508
|
+
],
|
509
|
+
});
|
510
|
+
var serializedTeam1 = {
|
511
|
+
id: 1, name: 'Team 1', vehicle_id: 123,
|
512
|
+
members_attributes: [{id: 352435, user_id: 100500, slot_id: 200425}, {id: 235433, user_id: 100501, slot_id: 200426}],
|
513
|
+
};
|
514
|
+
|
515
|
+
expect(Team.config.serializer.serialize(team1)).toEqual(serializedTeam1);
|
516
|
+
}));
|
517
|
+
});
|
456
518
|
});
|
457
519
|
});
|
@@ -411,7 +411,7 @@
|
|
411
411
|
* @returns {*} A new object or array that is ready for JSON serialization
|
412
412
|
*/
|
413
413
|
Serializer.prototype.serialize = function (data) {
|
414
|
-
var result =
|
414
|
+
var result = angular.copy(data),
|
415
415
|
self = this;
|
416
416
|
|
417
417
|
if (angular.isObject(result)) {
|
@@ -435,6 +435,8 @@
|
|
435
435
|
});
|
436
436
|
}
|
437
437
|
|
438
|
+
result = this.serializeValue(result);
|
439
|
+
|
438
440
|
return result;
|
439
441
|
};
|
440
442
|
|
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.
|
4
|
+
version: 1.2.3
|
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-
|
12
|
+
date: 2015-02-09 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:
|
@@ -19,8 +19,8 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
- .gitignore
|
23
|
-
- .travis.yml
|
22
|
+
- ".gitignore"
|
23
|
+
- ".travis.yml"
|
24
24
|
- CHANGELOG.md
|
25
25
|
- EXAMPLES.md
|
26
26
|
- Gemfile
|
@@ -71,17 +71,17 @@ require_paths:
|
|
71
71
|
- lib
|
72
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.2.2
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: AngularJS add-on resource add-on for integrating with Rails
|