fun_with_json_api 0.0.9 → 0.0.10

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
  SHA1:
3
- metadata.gz: 24f1af89657a79d42e1aec3122486e3196635738
4
- data.tar.gz: 8631e1b1c88dc60f130a3abfbe4c68c0fc067287
3
+ metadata.gz: a119836d10ecb97a0691d85556e582a806c46586
4
+ data.tar.gz: 18e1f85f672338ad34f9766d7e184a78e6bcca61
5
5
  SHA512:
6
- metadata.gz: 935eddfa83c835df7c086db35e11a22b8df4a3fc765d482b84508cd5007eddc35231b3f9c319f79b7874bf8054ff79663c153641da02b6f9ef651be5e3d510eb
7
- data.tar.gz: 78aa8524d664300cdc9d2baceb3e817235964afb46c7021824806ff2f97055fddd431e3168549300fb4ae8f3a806dde0494594bae242a083da44f20587a48446
6
+ metadata.gz: a237a4953d522efb48caf822ad83e38d61292199e12df4a527e1ab9ee4c1c4bf06b37cafa51f5ca557dc9f9ee87af16514b7a18760ddef5745e1b2b1b2537350
7
+ data.tar.gz: 90895829f7b851d0c5f6acc0b9cfdc6a4c16f73c87ffacdff68bf3069cc853e5bdfc7e84c613125b97d6a4dfae95c5f7b04dade005cc174f6f35b8cfd1deea68
@@ -55,7 +55,7 @@ module FunWithJsonApi
55
55
 
56
56
  def check_resource_is_authorized!(resource, id_value)
57
57
  SchemaValidators::CheckResourceIsAuthorised.call(
58
- resource, id_value, deserializer, prefix: "/data/relationships/#{name}/data"
58
+ resource, id_value, deserializer, resource_pointer: "/data/relationships/#{name}"
59
59
  )
60
60
  end
61
61
 
@@ -79,7 +79,7 @@ module FunWithJsonApi
79
79
  def build_missing_relationship_error(id_value, message = nil)
80
80
  message ||= missing_resource_debug_message(id_value)
81
81
  payload = ExceptionPayload.new
82
- payload.pointer = "/data/relationships/#{name}/data/id"
82
+ payload.pointer = "/data/relationships/#{name}"
83
83
  payload.detail = "Unable to find '#{deserializer.type}' with matching id"\
84
84
  ": #{id_value.inspect}"
85
85
  Exceptions::MissingRelationship.new(message, payload)
@@ -120,7 +120,7 @@ module FunWithJsonApi
120
120
  next if collection_ids.include?(resource_id)
121
121
 
122
122
  ExceptionPayload.new.tap do |payload|
123
- payload.pointer = "/data/relationships/#{name}/data/#{index}/id"
123
+ payload.pointer = "/data/relationships/#{name}/data/#{index}"
124
124
  payload.detail = "Unable to find '#{deserializer.type}' with matching id"\
125
125
  ": \"#{resource_id}\""
126
126
  end
@@ -144,7 +144,7 @@ module FunWithJsonApi
144
144
  def build_invalid_resource_exception_payload(failed_resources_hash, failure_message_or_callable)
145
145
  failed_resources_hash.map do |index, resource|
146
146
  failure_message = failure_message_for_resource(resource, failure_message_or_callable)
147
- ExceptionPayload.new(detail: failure_message, pointer: "/data/#{index}/id")
147
+ ExceptionPayload.new(detail: failure_message, pointer: "/data/#{index}")
148
148
  end
149
149
  end
150
150
  end
@@ -87,7 +87,7 @@ module FunWithJsonApi
87
87
  message = "#{deserializer_name} was unable to find resource by '#{deserializer.id_param}'"\
88
88
  ": '#{document_id}'"
89
89
  payload = ExceptionPayload.new
90
- payload.pointer = '/data/id'
90
+ payload.pointer = '/data'
91
91
  payload.detail = missing_resource_message
92
92
  Exceptions::MissingResource.new(message, payload)
93
93
  end
@@ -48,7 +48,7 @@ module FunWithJsonApi
48
48
  def build_missing_resource_payload(collection_ids, resource_id, index)
49
49
  unless collection_ids.include?(resource_id)
50
50
  ExceptionPayload.new(
51
- pointer: "#{prefix}/#{index}/id",
51
+ pointer: "#{prefix}/#{index}",
52
52
  detail: missing_resource_message(resource_id)
53
53
  )
54
54
  end
@@ -44,7 +44,7 @@ module FunWithJsonApi
44
44
  def build_unauthorized_resource_payload(resource, index)
45
45
  unless deserializer.resource_authorizer.call(resource)
46
46
  ExceptionPayload.new(
47
- pointer: "#{prefix}/#{index}/id",
47
+ pointer: "#{prefix}/#{index}",
48
48
  detail: unauthorized_resource_message(collection_ids[index])
49
49
  )
50
50
  end
@@ -10,13 +10,13 @@ module FunWithJsonApi
10
10
  attr_reader :resource
11
11
  attr_reader :resource_id
12
12
  attr_reader :deserializer
13
- attr_reader :prefix
13
+ attr_reader :resource_pointer
14
14
 
15
- def initialize(resource, resource_id, deserializer, prefix: '/data')
15
+ def initialize(resource, resource_id, deserializer, resource_pointer: '/data')
16
16
  @resource = resource
17
17
  @resource_id = resource_id
18
18
  @deserializer = deserializer
19
- @prefix = prefix
19
+ @resource_pointer = resource_pointer
20
20
  end
21
21
 
22
22
  def call
@@ -24,7 +24,7 @@ module FunWithJsonApi
24
24
  raise Exceptions::UnauthorisedResource.new(
25
25
  "resource_authorizer method for '#{deserializer.type}' returned a false value",
26
26
  ExceptionPayload.new(
27
- pointer: "#{prefix}/id",
27
+ pointer: resource_pointer,
28
28
  detail: unauthorized_resource_message
29
29
  )
30
30
  )
@@ -1,3 +1,3 @@
1
1
  module FunWithJsonApi
2
- VERSION = '0.0.9'.freeze
2
+ VERSION = '0.0.10'.freeze
3
3
  end