jsonapi_parameters 0.4.5 → 1.0.0

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: 3ee3931b91f3d2888bec069517cf1c5bb14f88de124306b7ffc3800c202a3a80
4
- data.tar.gz: 06d417d811e0224f7c01117a35d4ce5ffbe7a25e28e9fc129a73cf312f2e9c9c
3
+ metadata.gz: daa7f46ec2ca9f23be7199bf5b8ee043a1b40317ed96070f9b0025a624328eeb
4
+ data.tar.gz: 29b227bd32c0b86cb6b5e29c368bc4728a445c369f22852037b3ff6f8e929b07
5
5
  SHA512:
6
- metadata.gz: 751a7a370207289e62462d826d4306bb5189e313a4c747bd41111bc5d500e4342b4b553c4072208271f84368e21a17c901fcca63b570100117f087ee71d3c7c2
7
- data.tar.gz: 7eed067e7e60f58ed60f067a1365a7d6045c08d6972dc595da88fd325863d6d6e109c0e73fcb7b4450986d6111f422ba98b1c738fbcb273d8bf233b0244bd436
6
+ metadata.gz: 30da56dbc5654aed7331e5db54f54da59414fdf747a97c75755ba184af9e813a9ef50f7f2251f4af418ca04d11b54d353d1d4ca7c1e12a638e2049fa7bcae972
7
+ data.tar.gz: a67da822ec846764be2cc6a999a6a70655b7816b5be9b733770a2f4ec32246a39cf587260a2fdfe6fa6836fe0290cc0e08088b873a8649fb2e61ab1fab59d839
@@ -69,11 +69,11 @@ module JsonApi::Parameters
69
69
  end
70
70
 
71
71
  def handle_to_many_relation(relationship_key, relationship_value)
72
- with_inclusion = true
72
+ with_inclusion = !relationship_value.empty?
73
73
 
74
- vals = relationship_value.map do |relationship_value|
75
- related_id = relationship_value.dig(:id)
76
- related_type = relationship_value.dig(:type)
74
+ vals = relationship_value.map do |relationship|
75
+ related_id = relationship.dig(:id)
76
+ related_type = relationship.dig(:type)
77
77
 
78
78
  included_object = find_included_object(
79
79
  related_id: related_id, related_type: related_type
@@ -82,13 +82,13 @@ module JsonApi::Parameters
82
82
  # If at least one related object has not been found in `included` tree,
83
83
  # we should not attempt to "#{relationship_key}_attributes" but
84
84
  # "#{relationship_key}_ids" instead.
85
- with_inclusion = with_inclusion ? !included_object.empty? : with_inclusion
85
+ with_inclusion &= !included_object.empty?
86
86
 
87
87
  if with_inclusion
88
88
  included_object.delete(:type)
89
89
  included_object[:attributes].merge(id: related_id)
90
90
  else
91
- relationship_value.dig(:id)
91
+ relationship.dig(:id)
92
92
  end
93
93
  end
94
94
 
@@ -1,5 +1,5 @@
1
1
  module JsonApi
2
2
  module Parameters
3
- VERSION = '0.4.5'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Visuality