jsonapi-serializers 0.6.1 → 0.6.2
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/lib/jsonapi-serializers/serializer.rb +17 -14
- data/lib/jsonapi-serializers/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22bd1a0e4edb6afa842b9aea4e12083b376b2c3a
|
4
|
+
data.tar.gz: fb1c32bdf48825ffbc32db8078c6daf1c7c31f5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb9216808ac7835e95dde7a428bc1af161d4940d72ed67737a864294777894249cbbb405e3e544a6104b798db3d6728dbc1cd163bb29bddf283bf6c438536d2
|
7
|
+
data.tar.gz: fee4e082f317e1cb3486829dbdfad8016834299b39e290e664e27fdd91d0914e7a246ae43ffa0bd875d773013a91bb3f2105d7563dda3e50bb24dcd906c6320c
|
@@ -85,7 +85,8 @@ module JSONAPI
|
|
85
85
|
|
86
86
|
def links
|
87
87
|
data = {}
|
88
|
-
data
|
88
|
+
data['self'] = self_link if self_link
|
89
|
+
data
|
89
90
|
end
|
90
91
|
|
91
92
|
def relationships
|
@@ -107,15 +108,13 @@ module JSONAPI
|
|
107
108
|
# Spec: Resource linkage MUST be represented as one of the following:
|
108
109
|
# - null for empty to-one relationships.
|
109
110
|
# http://jsonapi.org/format/#document-structure-resource-relationships
|
110
|
-
data[formatted_attribute_name]
|
111
|
+
data[formatted_attribute_name]['data'] = nil
|
111
112
|
else
|
112
113
|
related_object_serializer = JSONAPI::Serializer.find_serializer(object)
|
113
|
-
data[formatted_attribute_name]
|
114
|
-
'
|
115
|
-
|
116
|
-
|
117
|
-
},
|
118
|
-
})
|
114
|
+
data[formatted_attribute_name]['data'] = {
|
115
|
+
'type' => related_object_serializer.type.to_s,
|
116
|
+
'id' => related_object_serializer.id.to_s,
|
117
|
+
}
|
119
118
|
end
|
120
119
|
end
|
121
120
|
end
|
@@ -136,7 +135,7 @@ module JSONAPI
|
|
136
135
|
# - an array of linkage objects for non-empty to-many relationships.
|
137
136
|
# http://jsonapi.org/format/#document-structure-resource-relationships
|
138
137
|
if @_include_linkages.include?(formatted_attribute_name)
|
139
|
-
data[formatted_attribute_name]
|
138
|
+
data[formatted_attribute_name]['data'] = []
|
140
139
|
objects = has_many_relationship(attribute_name, attr_data) || []
|
141
140
|
objects.each do |obj|
|
142
141
|
related_object_serializer = JSONAPI::Serializer.find_serializer(obj)
|
@@ -323,15 +322,19 @@ module JSONAPI
|
|
323
322
|
data = {
|
324
323
|
'id' => serializer.id.to_s,
|
325
324
|
'type' => serializer.type.to_s,
|
326
|
-
'attributes' => serializer.attributes,
|
327
325
|
}
|
328
326
|
|
329
327
|
# Merge in optional top-level members if they are non-nil.
|
330
328
|
# http://jsonapi.org/format/#document-structure-resource-objects
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
329
|
+
# Call the methods once now to avoid calling them twice when evaluating the if's below.
|
330
|
+
attributes = serializer.attributes
|
331
|
+
links = serializer.links
|
332
|
+
relationships = serializer.relationships
|
333
|
+
meta = serializer.meta
|
334
|
+
data['attributes'] = attributes if !attributes.nil?
|
335
|
+
data['links'] = links if !links.nil?
|
336
|
+
data['relationships'] = relationships if !relationships.empty?
|
337
|
+
data['meta'] = meta if !meta.nil?
|
335
338
|
data
|
336
339
|
end
|
337
340
|
class << self; protected :serialize_primary; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi-serializers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Fotinakis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.2.2
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Pure Ruby readonly serializers for the JSON:API spec.
|
@@ -132,4 +132,3 @@ test_files:
|
|
132
132
|
- spec/spec_helper.rb
|
133
133
|
- spec/support/factory.rb
|
134
134
|
- spec/support/serializers.rb
|
135
|
-
has_rdoc:
|