restpack_serializer 0.5.1 → 0.5.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e057f9443e4458620f07fe24d2c231caac2aab7
|
4
|
+
data.tar.gz: e84c048d7a562944581eaec14e353147df4b0398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc7334b9da94b802974a40351c7be43860d5691129cdd1d8f84aa56c3e7ea68ba83ce454144c192bd64d439f9fb36e32551361f852ef512d80d260d51ee04f9f
|
7
|
+
data.tar.gz: e08a930f72863feffacea046f8e5fbaacf6a941416f2302a68eef87ba0b7bbe99397fbff40f3d916e46fd2541d8ad21d1e74e1ed4355cfa49f22710c0a6fc492
|
data/README.md
CHANGED
@@ -57,7 +57,7 @@ end
|
|
57
57
|
}
|
58
58
|
```
|
59
59
|
|
60
|
-
`as_json` accepts an optional `context` hash parameter which can be used
|
60
|
+
`as_json` accepts an optional `context` hash parameter which can be used by your Serializers to customize their output:
|
61
61
|
|
62
62
|
```ruby
|
63
63
|
class AlbumSerializer
|
@@ -71,7 +71,7 @@ module RestPack
|
|
71
71
|
if foreign_key_value
|
72
72
|
data[:links][association.name.to_sym] = foreign_key_value.to_s
|
73
73
|
end
|
74
|
-
elsif association.macro == :has_many
|
74
|
+
elsif association.macro == :has_many
|
75
75
|
ids = model.send(association.name).pluck(:id).map { |id| id.to_s }
|
76
76
|
|
77
77
|
data[:links] ||= {}
|
@@ -133,7 +133,7 @@ describe RestPack::Serializer::Paging do
|
|
133
133
|
album_model = MyApp::Album.find(album[:id])
|
134
134
|
|
135
135
|
album[:links][:artist].should == album_model.artist_id.to_s
|
136
|
-
|
136
|
+
(page[:songs].map { |song| song[:id] } - album[:links][:songs]).empty?.should be_truthy
|
137
137
|
end
|
138
138
|
|
139
139
|
context "with includes as comma delimited string" do
|
@@ -159,9 +159,7 @@ describe RestPack::Serializer do
|
|
159
159
|
artist_with_fans = FactoryGirl.create :artist_with_fans
|
160
160
|
|
161
161
|
json = artist_serializer.as_json(artist_with_fans)
|
162
|
-
json[:links].should == {
|
163
|
-
fans: artist_with_fans.fans.collect {|obj| obj.id.to_s }
|
164
|
-
}
|
162
|
+
json[:links][:fans].should == artist_with_fans.fans.collect {|obj| obj.id.to_s }
|
165
163
|
end
|
166
164
|
end
|
167
165
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|