jsonapi-serializers 0.6.1 → 0.6.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: d89dc4f009841a5431c7e79060da4208c2d7dde2
4
- data.tar.gz: 1eb85ed60e4d91ba8f33ed28a8151ac3ff21cf71
3
+ metadata.gz: 22bd1a0e4edb6afa842b9aea4e12083b376b2c3a
4
+ data.tar.gz: fb1c32bdf48825ffbc32db8078c6daf1c7c31f5d
5
5
  SHA512:
6
- metadata.gz: fa10630f9a9181a194e831cf538d65c7fcafa910ee7054e3838efbe30ef1775eb447b4f4eb84c4900d9fa4a99a539caf9df6d47f0e8db3299a0b4116ec0d9c08
7
- data.tar.gz: c8d6f28e77762831850999491d2f05237ed0a4c2fd4215a09d88b7d8ccdefa2732955da77ebe1009bbc43cf6270e659ffb830f1544880c234783db0495c20767
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.merge!({'self' => self_link}) if self_link
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].merge!({'data' => nil})
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].merge!({
114
- 'data' => {
115
- 'type' => related_object_serializer.type.to_s,
116
- 'id' => related_object_serializer.id.to_s,
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].merge!({'data' => []})
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
- data.merge!({'attributes' => serializer.attributes}) if !serializer.attributes.nil?
332
- data.merge!({'links' => serializer.links}) if !serializer.links.nil?
333
- data.merge!({'relationships' => serializer.relationships}) unless serializer.relationships.empty?
334
- data.merge!({'meta' => serializer.meta}) if !serializer.meta.nil?
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
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Serializer
3
- VERSION = '0.6.1'
3
+ VERSION = '0.6.2'
4
4
  end
5
5
  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.1
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-21 00:00:00.000000000 Z
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.4.5
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: