snfoil-rails 0.4.4 → 0.4.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: cbabacb778a70d87face8ff2953666e66b509f575ab91c7010b3c7bf71a050a2
4
- data.tar.gz: 1dfea0059c61d63532022c2537482456942ca05c33991f64a2b725b452ef1c0a
3
+ metadata.gz: a4aa9e8502480e615c440aca9f2bc70f507b94dc0a2e57a9c0b3d02cb2cb9d2d
4
+ data.tar.gz: d607d2fe7c5c1c8dd9ff69bace09247f3ec721fd5c1e4767592f6e7ad182dfb9
5
5
  SHA512:
6
- metadata.gz: 5bdc25d574bcc9e1a95f5783beadcdfd7d44d87384d105f5ce7534b51c1ea4e5837365d0758c4152c9940293445ecdc484d781df1ada201148d01d24bdff1e31
7
- data.tar.gz: 7d80030755877131ec54644096f696b051c3930de228c56d767eb035c6288b0c1f06d610dbabf8b646283e05812d95af607084ac277c937efabd24eaebf826ca
6
+ metadata.gz: 25c8f8f25014f15a828795c95630e16714dd66f31bf50355819737b576a1248dcd0e592b33fd1b114b9a4fdbede8253f981b7246eade81d8654301c53949ff62
7
+ data.tar.gz: 99d2655356d0afea93703aa84768ebf90e91835e2d8eef689c6eafeca5bd659b02b37e9057f14785d806391fd69256936b768f497f7eabd7a68a40f246aa68ba
@@ -77,7 +77,7 @@ module SnFoil
77
77
  def data_id(attributes, data)
78
78
  if data[:id]
79
79
  attributes[:id] = data[:id]
80
- elsif object[:data][:'local:id']
80
+ elsif data[:'local:id']
81
81
  attributes[:lid] = data[:'local:id']
82
82
  end
83
83
  attributes
@@ -117,6 +117,7 @@ module SnFoil
117
117
  resource_data = data.dig(:relationships, key, :data)
118
118
  return attributes unless resource_data
119
119
 
120
+ resource_data = data_id(resource_data, resource_data)
120
121
  attribute_data = lookup_relationship(resource_data)
121
122
  relationship_data = { data: attribute_data || resource_data }
122
123
  attributes[opts.fetch(:key) { key }] = deserializer.new(relationship_data, **options, included: included).parse
@@ -128,6 +129,7 @@ module SnFoil
128
129
  return attributes unless array_data
129
130
 
130
131
  attributes[opts.fetch(:key) { key }] = array_data.map do |resource_data|
132
+ resource_data = data_id(resource_data, resource_data)
131
133
  attribute_data = lookup_relationship(resource_data)
132
134
  relationship_data = { data: attribute_data || resource_data }
133
135
  deserializer.new(relationship_data, **options, included: included).parse
@@ -136,7 +138,7 @@ module SnFoil
136
138
  end
137
139
 
138
140
  def lookup_relationship(type:, id: nil, lid: nil, **_opts)
139
- raise ::ArgumentError, 'missing keyword: id or lid' unless id || lid
141
+ raise ::ArgumentError, "missing keyword: id or lid for type: #{type}" unless id || lid
140
142
 
141
143
  included&.find do |x|
142
144
  x[:type].eql?(type) &&
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SnFoil
4
4
  module Rails
5
- VERSION = '0.4.4'
5
+ VERSION = '0.4.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snfoil-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Howes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-15 00:00:00.000000000 Z
12
+ date: 2020-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport