active_model_serializers_pg 0.0.4 → 0.0.5
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fb040d4836aa84e29ba59590ac8bc4373528e31e5186cec1168538d52384fd0
|
4
|
+
data.tar.gz: a2ef8e881e358597aeb30145a73cbfdff5b7ed663d1c614ba5a40cbceba9d772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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)
|
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
|
|
data/spec/serializer_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe 'ArraySerializer' do
|
|
25
25
|
{
|
26
26
|
id: @note.id.to_s,
|
27
27
|
type: 'notes',
|
28
|
-
attributes: {
|
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: {
|
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: {
|
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: {
|
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: {
|
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: {
|
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: {
|
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: {
|
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: {
|
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: {
|
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: {
|
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: {
|
668
|
+
attributes: {},
|
669
669
|
relationships: {
|
670
670
|
custom_sorted_tags: {
|
671
671
|
data: [
|