active_model_serializers_pg 0.0.4 → 0.0.5

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
  SHA256:
3
- metadata.gz: 63d2090a2d7e9e33d8565156023d5c3dc75ea74c77baade84c5c0727d3ab917f
4
- data.tar.gz: d1abc37c7a6dade9d9bacb7584b5e630f81652a87d28849dacc6bcbb5291c7d9
3
+ metadata.gz: 0fb040d4836aa84e29ba59590ac8bc4373528e31e5186cec1168538d52384fd0
4
+ data.tar.gz: a2ef8e881e358597aeb30145a73cbfdff5b7ed663d1c614ba5a40cbceba9d772
5
5
  SHA512:
6
- metadata.gz: ec68d79eacdcbb257753fa6636236b406e2a57012aa68aba4d8f1ff564bd072653cfc6da4daa07ebe17bce5be0913d6e93da7cadccf6c4d637467d4026cdc21c
7
- data.tar.gz: 0a7726480564582f54afcc91b8f7666ceb8416a772a8b34623b252723bb36b545a19491894b07b06372cbbfc5313473e8b12f80899e4c7d6705bdaef10ac8235
6
+ metadata.gz: 30889a0c217b98a0a79296379fd7c399b414b223a3568133e796ef605ae938d013957052c939c65bed5a75fed3e64d08025bc83729a92d620d3fdb905aca13dd
7
+ data.tar.gz: 7ff699ff57696cece4ed3f54a2f3d8583f1d2bd2089f65ab842972d9c22c9a2a86360c20e4bd0e043f2532db8f54c332804e3038c3d65f35c3af6be4f297a56e
@@ -688,7 +688,7 @@ class JsonApiPgSql
688
688
  resource.serializer._attributes.select{|f|
689
689
  if ms.include? "include_#{f}?".to_sym
690
690
  ser = resource.serializer.new(nil, @options)
691
- ser.send("include_#{f}?".to_sym) # TODO: call the method
691
+ ser.send("include_#{f}?".to_sym)
692
692
  else
693
693
  true
694
694
  end
@@ -702,7 +702,7 @@ class JsonApiPgSql
702
702
  resource.serializer._reflections.keys.select{|f|
703
703
  if ms.include? "include_#{f}?".to_sym
704
704
  ser = resource.serializer.new(nil, @options)
705
- ser.send("include_#{f}?".to_sym) # TODO: call the method
705
+ ser.send("include_#{f}?".to_sym)
706
706
  else
707
707
  true
708
708
  end
@@ -735,6 +735,9 @@ class JsonApiPgSql
735
735
 
736
736
  def _attribute_fields_for(resource)
737
737
  attrs = Set.new(serializer_attributes(resource))
738
+ # JSON:API always excludes the `id`
739
+ # even if it's part of the serializer:
740
+ attrs = attrs - [resource.primary_key.to_sym]
738
741
  fields_for(resource).select { |f| attrs.include? f }.to_a
739
742
  end
740
743
 
@@ -1,3 +1,3 @@
1
1
  module ActiveModelSerializersPg
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -25,7 +25,7 @@ describe 'ArraySerializer' do
25
25
  {
26
26
  id: @note.id.to_s,
27
27
  type: 'notes',
28
- attributes: {id: @note.id, name: 'Title'},
28
+ attributes: {name: 'Title'},
29
29
  relationships: {tags: {data: [{id: @tag.id.to_s, type: 'tags'}]}},
30
30
  }
31
31
  ]
@@ -65,7 +65,7 @@ describe 'ArraySerializer' do
65
65
  {
66
66
  id: person.id.to_s,
67
67
  type: 'people',
68
- attributes: { id: person.id, full_name: 'Test User', attendance_name: 'User, Test' },
68
+ attributes: { full_name: 'Test User', attendance_name: 'User, Test' },
69
69
  }
70
70
  ]
71
71
  }.to_json
@@ -80,7 +80,7 @@ describe 'ArraySerializer' do
80
80
  {
81
81
  id: person.id.to_s,
82
82
  type: 'people',
83
- attributes: {id: person.id, full_name: 'Test User', attendance_name: 'ADMIN User, Test'}
83
+ attributes: {full_name: 'Test User', attendance_name: 'ADMIN User, Test'}
84
84
  }
85
85
  ]
86
86
  }.to_json
@@ -270,7 +270,7 @@ describe 'ArraySerializer' do
270
270
  data: {
271
271
  id: @note.id.to_s,
272
272
  type: 'notes',
273
- attributes: { id: @note.id, name: 'Title' },
273
+ attributes: { name: 'Title' },
274
274
  relationships: { tags: { data: [{id: @tag.id.to_s, type: 'tags'}] } }
275
275
  }
276
276
  }.to_json
@@ -424,7 +424,7 @@ describe 'ArraySerializer' do
424
424
  {
425
425
  id: tag.id.to_s,
426
426
  type: 'tags',
427
- attributes: { id: tag.id, name: 'My tag' },
427
+ attributes: { name: 'My tag' },
428
428
  relationships: { note: { data: { id: note.id.to_s, type: 'notes' } } },
429
429
  }
430
430
  ],
@@ -462,7 +462,7 @@ describe 'ArraySerializer' do
462
462
  {
463
463
  id: reviewer.id.to_s,
464
464
  type: 'users',
465
- attributes: { id: reviewer.id, name: 'Peter' },
465
+ attributes: { name: 'Peter' },
466
466
  relationships: {
467
467
  offers: { data: [] },
468
468
  reviewed_offers: { data: [{id: offer.id.to_s, type: 'offers'}] },
@@ -471,7 +471,7 @@ describe 'ArraySerializer' do
471
471
  {
472
472
  id: user.id.to_s,
473
473
  type: 'users',
474
- attributes: { id: user.id, name: 'John' },
474
+ attributes: { name: 'John' },
475
475
  relationships: {
476
476
  offers: { data: [{id: offer.id.to_s, type: 'offers'}] },
477
477
  reviewed_offers: { data: [] },
@@ -522,7 +522,7 @@ describe 'ArraySerializer' do
522
522
  {
523
523
  id: tag.id.to_s,
524
524
  type: 'tag_with_notes',
525
- attributes: { id: tag.id, name: 'My tag' },
525
+ attributes: { name: 'My tag' },
526
526
  relationships: { note: { data: { id: note.id.to_s, type: 'notes' } } },
527
527
  }
528
528
  ]
@@ -581,7 +581,7 @@ describe 'ArraySerializer' do
581
581
  {
582
582
  id: @user.id.to_s,
583
583
  type: 'users',
584
- attributes: {id: @user.id, name: 'John', mobile: '51111111'},
584
+ attributes: {name: 'John', mobile: '51111111'},
585
585
  relationships: {
586
586
  offers: {data: []},
587
587
  address: {data: {id: address.id.to_s, type: 'addresses'}},
@@ -601,7 +601,7 @@ describe 'ArraySerializer' do
601
601
  {
602
602
  id: @user.id.to_s,
603
603
  type: 'users',
604
- attributes: {id: @user.id, name: 'John'},
604
+ attributes: {name: 'John'},
605
605
  relationships: {
606
606
  offers: {data: []},
607
607
  reviewed_offers: {data: []},
@@ -629,7 +629,7 @@ describe 'ArraySerializer' do
629
629
  {
630
630
  id: note.id.to_s,
631
631
  type: 'notes',
632
- attributes: {id: note.id},
632
+ attributes: {},
633
633
  relationships: {
634
634
  sorted_tags: {
635
635
  data: [
@@ -665,7 +665,7 @@ describe 'ArraySerializer' do
665
665
  {
666
666
  id: note.id.to_s,
667
667
  type: 'notes',
668
- attributes: {id: note.id},
668
+ attributes: {},
669
669
  relationships: {
670
670
  custom_sorted_tags: {
671
671
  data: [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_model_serializers_pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul A. Jungwirth