jsonapi-realizer 6.2.3 → 6.3.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: bdbcdbae0d050e594266eeb3a84ee99ac64ca19febc7ba1d86d823479e832f0d
4
- data.tar.gz: 6c5bafdb777e5f5722c0ce14cd2e6978bd727409b9a09ea1e68c5ecc07671434
3
+ metadata.gz: bdedd4d38134e7c8f572f6e4583d7d6276fc4a6e27f67964b548992d63b67272
4
+ data.tar.gz: 2c6f6d1d40732ec66681da213f7ea19dd9c8e6cf8c5dcc460b58ea1f2c15cdea
5
5
  SHA512:
6
- metadata.gz: 1b3c4810879476f7d3d748a16a8538c599f3e288cb7aa55d83bacb7727eb9abc135e12afd9140b6650cd062e8629b6cbf307f655c3fcecaa20bbd71db3299e9b
7
- data.tar.gz: 40eeabceb511afea21c0baab9c840c9963ba05a6b3c286b2464a80391e8d3ebe71e700e78ca7b0ecc99fe1105eab090f970983a601e61bf17444414e0366dd0c
6
+ metadata.gz: 294c15608987a6d521438a56b070c98d4b7b3d432bc47562d995102b95107c4d27ab2b5b1b45c1a4c2950349db5631b3f4a6f4cb624b207e8337371192b0fd59
7
+ data.tar.gz: 5fba1d580be4e3a7270214ec1a847a9ddf5bb2fe4f618c6f889820c2bb1ef5ec5dd721531e95f3cf958991dc408070855b93664d6b885cd36ec82d4c108d05d2
@@ -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")
@@ -6,9 +6,14 @@ module JSONAPI
6
6
  class ResourceRelationshipNotFound < Error
7
7
  attr_accessor(:name)
8
8
  attr_accessor(:realizer)
9
+ attr_accessor(:key)
9
10
 
10
11
  def message
11
- "#{realizer} doesn't define the relationship #{name}"
12
+ if key
13
+ "#{realizer} doesn't define the relationship #{name} with #{key}"
14
+ else
15
+ "#{realizer} doesn't define the relationship #{name}"
16
+ end
12
17
  end
13
18
  end
14
19
  end
@@ -27,8 +27,8 @@ module JSONAPI
27
27
  end
28
28
 
29
29
  validates_presence_of(:intent)
30
- validates_presence_of(:parameters, allow_empty: true)
31
- validates_presence_of(:headers, allow_empty: true)
30
+ validates_presence_of(:parameters, allow_empty: true, allow_blank: true)
31
+ validates_presence_of(:headers, allow_empty: true, allow_blank: true)
32
32
 
33
33
  identifier(JSONAPI::Realizer.configuration.default_identifier)
34
34
 
@@ -126,7 +126,7 @@ module JSONAPI
126
126
  end
127
127
 
128
128
  def include?
129
- parameters.key?("include") && parameters.fetch("include").respond_to?(:split)
129
+ parameters.key?("include") && parameters.fetch("include").respond_to?(:split) && parameters.fetch("include").split(/\s*,\s*/).any?
130
130
  end
131
131
 
132
132
  def includes
@@ -155,6 +155,8 @@ module JSONAPI
155
155
  end.first
156
156
  end
157
157
  # [["account", "photographs"], ["comments"], ["comments", "account"]]
158
+ rescue Error::ResourceRelationshipNotFound => _relationship_not_found
159
+ raise(Error::ResourceRelationshipNotFound, name:, materializer: self, key: "include")
158
160
  end
159
161
 
160
162
  def selects?
@@ -321,7 +323,7 @@ module JSONAPI
321
323
 
322
324
  relation_configuration = relation(name).realizer_class.configuration
323
325
 
324
- if data.kind_of?(Array)
326
+ if data.is_a?(Array)
325
327
  [name, relation_configuration.adapter.find_many(relation_configuration.model_class, { id: data.map { |value| value.fetch("id") } })]
326
328
  else
327
329
  [name, relation_configuration.adapter.find_one(relation_configuration.model_class, data.fetch("id"))]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSONAPI
4
4
  module Realizer
5
- VERSION = "6.2.3"
5
+ VERSION = "6.3.0"
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.3
4
+ version: 6.3.0
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-20 00:00:00.000000000 Z
11
+ date: 2024-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport