jsonapi-serializers 0.2.2 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32d0b6019eb7a0da9ded6bd4fa6a62ba74ddb8a2
4
- data.tar.gz: c027a23983f08270443743e40dcc52c1d457da22
3
+ metadata.gz: 0ecd4a38af955857a58bcadcdf88ef7e2f658f82
4
+ data.tar.gz: b47bc0a6ce3a5732d3f76bea5f87d425664afc9c
5
5
  SHA512:
6
- metadata.gz: 5e0177a3eba071683095c37d2a498c4834b4061535e630c95d38c6ca03cf83a3c698198b82db6453c46c398fad00f2f818d03de3ace4183839d726800fd64d30
7
- data.tar.gz: 194a65e5ab124effa18d84de1f0924340bd71519692064074b7af4a7128af2102be9717dfef7e254087efe9034d7d4c22cfd36bba8307d92a9ed1c105ac1662f
6
+ metadata.gz: 84839b9fa483ad6cff15f7c152045ba5e78c0aed12e354898b80d1532350b4d5eefa05d45ee686ac402adf8c7e613fcb7cbb96aadd80b8d0c6b50b498e0ce6e7
7
+ data.tar.gz: afe84502165a840780bd94f54974a41a568f13e1c55efce92d21f7accb26c7aa07fbe30b2badff09eba60e4ca0b63637daa5864c4360fac3e8dfbdefe6b253e6
data/README.md CHANGED
@@ -429,6 +429,7 @@ end
429
429
 
430
430
  ## Release notes
431
431
 
432
+ * v0.2.3: Support serializers with no attributes.
432
433
  * v0.2.2: Compliance fix for excluding empty relationship objects.
433
434
  * v0.2.1: Compliance fix for self links.
434
435
  * v0.2.0: Initial release with support for the final v1 JSON API spec.
@@ -139,6 +139,7 @@ module JSONAPI
139
139
  end
140
140
 
141
141
  def attributes
142
+ return {} if self.class.attributes_map.nil?
142
143
  attributes = {}
143
144
  self.class.attributes_map.each do |attribute_name, attr_data|
144
145
  next if !should_include_attr?(attr_data[:options][:if], attr_data[:options][:unless])
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Serializer
3
- VERSION = '0.2.2'
3
+ VERSION = '0.2.3'
4
4
  end
5
5
  end
@@ -275,6 +275,18 @@ describe JSONAPI::Serializer do
275
275
  })
276
276
  end
277
277
  end
278
+ it 'can serialize primary data for an empty serializer with no attributes' do
279
+ post = create(:post)
280
+ primary_data = serialize_primary(post, {serializer: MyApp::EmptySerializer})
281
+ expect(primary_data).to eq({
282
+ 'id' => '1',
283
+ 'type' => 'posts',
284
+ 'attributes' => {},
285
+ 'links' => {
286
+ 'self' => '/posts/1',
287
+ },
288
+ })
289
+ end
278
290
  end
279
291
 
280
292
  describe 'JSONAPI::Serializer.serialize' do
@@ -95,4 +95,8 @@ module MyApp
95
95
  context.fetch(:hide_body, false)
96
96
  end
97
97
  end
98
+
99
+ class EmptySerializer
100
+ include JSONAPI::Serializer
101
+ end
98
102
  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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Fotinakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-08 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport