jsonapi-realizer 6.2.2 → 6.2.4

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: 76035465cf3254f1210f6fb47c9fa56774d0a7564456722a1f5f2845399e303b
4
- data.tar.gz: a2ca1648916cac59450a0d01fd9d801c65b466d4c4db86e930d74cd966fdc694
3
+ metadata.gz: 33ccbc88f14ef738c2dbb2e5c2045bd3a74109d699bd3e0d9706455d2fa71f31
4
+ data.tar.gz: 39822d29321c8f54440c5be6f4f140a3fb13e13e24ae4a3a90d3f07a04402371
5
5
  SHA512:
6
- metadata.gz: d2a961ef650cf889f4637a19c9ed606867a9cf45bfabd267df96b846eb576d10ae060e8073f2606f24e4a812c9f67298e37e721c6e2644212b527f651e544aaf
7
- data.tar.gz: 9766f382f722a9b18a982c33476940bf960966cb33189b4ddeb6a1c00b6cfdd853e967dbdd6677df673621fbcbe5c7d514904ae1c6bc7d995ea21bda4540dca5
6
+ metadata.gz: 177c312e93401ba515e396516e0cc41d883f4fed36858ff6a30d23ee4bdef157fe750e3aa079f0523b6a64578c4d10fc13a9403149740d7bb2f12c8b3b81400d
7
+ data.tar.gz: b7c225733a3cb9f11f97443b1f18e25458f24789e4c64526cdd9cf6f38be2aeab1d8748174aaed2ccdaaadf9e9de91cfe9d47d38985c4ac123c50acbb9d2a46a
@@ -123,7 +123,7 @@ module JSONAPI
123
123
 
124
124
  private def attributes
125
125
  return unless data
126
- return {} unless data["attributes"].kind_of?(Hash)
126
+ return {} unless data["attributes"].is_a?(Hash)
127
127
 
128
128
  data
129
129
  .fetch("attributes")
@@ -133,7 +133,7 @@ module JSONAPI
133
133
 
134
134
  private def relationships
135
135
  return unless data
136
- return {} unless data["relationships"].kind_of?(Hash)
136
+ return {} unless data["relationships"].is_a?(Hash)
137
137
 
138
138
  data
139
139
  .fetch("relationships")
@@ -73,7 +73,15 @@ module JSONAPI
73
73
  end
74
74
 
75
75
  def paginate?
76
- parameters.key?("page") && (parameters.fetch("page").key?("limit") || parameters.fetch("page").key?("offset"))
76
+ parameters.key?("page") && parameters.fetch("page").respond_to?(:fetch) && (paginate_limit? || paginate_offset?)
77
+ end
78
+
79
+ private def paginate_limit?
80
+ parameters.fetch("page").key?("limit")
81
+ end
82
+
83
+ private def paginate_offset?
84
+ parameters.fetch("page").key?("offset")
77
85
  end
78
86
 
79
87
  def pagination
@@ -84,7 +92,7 @@ module JSONAPI
84
92
  end
85
93
 
86
94
  def sorting?
87
- parameters.key?("sort")
95
+ parameters.key?("sort") && parameters.fetch("sort").respond_to?(:split)
88
96
  end
89
97
 
90
98
  def sorts
@@ -105,7 +113,7 @@ module JSONAPI
105
113
  end
106
114
 
107
115
  def filtering?
108
- parameters.key?("filter")
116
+ parameters.key?("filter") && parameters.fetch("filter").respond_to?(:transform_keys)
109
117
  end
110
118
 
111
119
  def filters
@@ -118,7 +126,7 @@ module JSONAPI
118
126
  end
119
127
 
120
128
  def include?
121
- parameters.key?("include")
129
+ parameters.key?("include") && parameters.fetch("include").respond_to?(:split) && parameters.fetch("include").split(/\s*,\s*/).any?
122
130
  end
123
131
 
124
132
  def includes
@@ -150,7 +158,7 @@ module JSONAPI
150
158
  end
151
159
 
152
160
  def selects?
153
- parameters.key?("fields")
161
+ parameters.key?("fields") && parameters.fetch("fields").respond_to?(:transform_keys)
154
162
  end
155
163
 
156
164
  def selects
@@ -167,7 +175,6 @@ module JSONAPI
167
175
  end
168
176
 
169
177
  def attributes
170
- return {} unless data["attributes"].kind_of?(Hash)
171
178
  @attributes ||= data
172
179
  .fetch("attributes")
173
180
  .transform_keys(&:underscore)
@@ -175,7 +182,6 @@ module JSONAPI
175
182
  end
176
183
 
177
184
  def relationships
178
- return {} unless data["relationships"].kind_of?(Hash)
179
185
  @relationships ||= data
180
186
  .fetch("relationships")
181
187
  .transform_keys(&:underscore)
@@ -283,7 +289,7 @@ module JSONAPI
283
289
  end
284
290
 
285
291
  private def data?
286
- parameters.key?("data")
292
+ parameters.key?("data") && (parameters.fetch("data").respond_to?(:fetch) || parameters.fetch("data").respond_to?(:map))
287
293
  end
288
294
 
289
295
  private def data
@@ -297,11 +303,11 @@ module JSONAPI
297
303
  end
298
304
 
299
305
  private def attributes?
300
- data.key?("attributes")
306
+ data.key?("attributes") && data.fetch("attributes").respond_to?(:fetch)
301
307
  end
302
308
 
303
309
  private def relationships?
304
- data.key?("relationships")
310
+ data.key?("relationships") && data.fetch("relationships").respond_to?(:fetch)
305
311
  end
306
312
 
307
313
  private def scope
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSONAPI
4
4
  module Realizer
5
- VERSION = "6.2.2"
5
+ VERSION = "6.2.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-realizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.2
4
+ version: 6.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-18 00:00:00.000000000 Z
11
+ date: 2023-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport