jsonapi-realizer 6.0.0 → 6.1.1

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: c3c9404082ffd310a2b2922f25f9c24f9a5f64577796c26dd0bea7a68860ca4f
4
- data.tar.gz: 1670a5f8bc193e4cc5a5fcafd0d5ae59a89184cbba2e1cbc18405ee10473d21b
3
+ metadata.gz: c68ffbcd4a507dfa58fe1951023e0d1ef4d362b841138542b25a051a8add752c
4
+ data.tar.gz: f56185a4a2948a3e1ba1364faaf02803ba299c6b1652208ce127fa042a88f5ed
5
5
  SHA512:
6
- metadata.gz: 93539ab4c704129aae40144231ef5a79b548537ef6811e988aad76323e30b6a27e890b657df8c190742e5ed00cebf6a3bd359a136158d9696fc8587900cd6ad8
7
- data.tar.gz: 561d004fecfe5fef5b082f70cd9c61af7ef53b602710b9b234c08833ef826a08b02bf59a3ff318fb5087bfda90b52202123d069627ed4368667a8659c3405b3d
6
+ metadata.gz: e5e346fceeab12188a36fd6c142b54fa8ff41cfa5dc49a55f201f92f454f00b4d2abf9ff32f51d347927f40079572442ed323de6ae4b35ac7c5ca213a38e4ca8
7
+ data.tar.gz: 9a73e8e119c82793a6f7d1508cb27490cabfa1daffa0b91e2269cd8202c2add58aa1faa6332371eaa39abb643c74e9ce20ab3c0d07f4a06270edcb3a3263c01a
data/README.md CHANGED
@@ -66,7 +66,7 @@ class PhotosController < ApplicationController
66
66
  end
67
67
 
68
68
  def index
69
- realizer = PhotoRealizer.new(
69
+ realizer = PhotoRealizer.new
70
70
  :intent => :index,
71
71
  :parameters => params,
72
72
  :headers => request.headers
@@ -213,26 +213,27 @@ You can see this resource controller used below:
213
213
  module V1
214
214
  class AccountsController < ::V1::ApplicationController
215
215
  def index
216
- realization = JSONAPI::Realizer.index(
217
- policy(Account).sanitize(:index, params),
218
- headers: request.headers,
219
- scope: policy_scope(Account),
220
- type: :accounts
216
+ realization = PhotoRealizer.new(
217
+ :intent => :index,
218
+ :scope => policy_scope(Account),
219
+ :parameters => policy(Account).sanitize(:index, params),
220
+ :headers => request.headers
221
221
  )
222
222
 
223
- authorize realization.relation
223
+ authorize realization.object
224
224
 
225
225
  render json: serialize(realization)
226
226
  end
227
227
 
228
228
  def create
229
- realization = JSONAPI::Realizer.create(
230
- policy(Account).sanitize(:create, params),
231
- headers: request.headers,
232
- scope: policy_scope(Account)
229
+ realization = PhotoRealizer.new(
230
+ :intent => :create,
231
+ :scope => policy_scope(Account),
232
+ :parameters => policy(Account).sanitize(:create, params),
233
+ :headers => request.headers
233
234
  )
234
235
 
235
- authorize realization.relation
236
+ authorize realization.object
236
237
 
237
238
  render json: serialize(realization)
238
239
  end
@@ -3,54 +3,34 @@
3
3
  module JSONAPI
4
4
  module Realizer
5
5
  module Controller
6
- private def reject_missing_content_type_header
7
- return if request.body.empty?
8
- return if request.headers.property?("Content-Type")
9
-
10
- raise(JSONAPI::Realizer.configuration.default_missing_content_type_exception)
11
- end
12
-
13
- private def reject_invalid_content_type_header
14
- reject_missing_content_type_header
15
-
16
- return if request.headers.fetch("Content-Type").include?(JSONAPI::MEDIA_TYPE)
17
-
18
- raise(JSONAPI::Realizer.configuration.default_invalid_content_type_exception)
19
- end
20
-
21
- private def reject_missing_root_property
22
- return if request.parameters.key?("body")
23
- return if request.paremters.key?("errors")
24
- return if request.paremters.key?("meta")
6
+ private def reject_missing_accept_type_header
7
+ return if request.body.read.empty?
8
+ return if request.headers.key?("HTTP_ACCEPT")
25
9
 
26
- raise(Error::MissingRootProperty)
10
+ raise(JSONAPI::Realizer.configuration.default_missing_accept_type_exception)
27
11
  end
28
12
 
29
- private def reject_invalid_root_property
30
- reject_missing_root_property
13
+ private def reject_invalid_accept_type_header
14
+ reject_missing_accept_type_header
31
15
 
32
- return unless request.parameters.key?("data") && (request.parameters.fetch("data").is_a?(Hash) || request.parameters.fetch("data").is_a?(Array))
33
- return unless request.parameters.key?("errors") && request.parameters.fetch("errors").is_a?(Array)
16
+ return if request.headers.fetch("HTTP_ACCEPT").include?(JSONAPI::MEDIA_TYPE)
34
17
 
35
- raise(Error::InvalidRootProperty)
18
+ raise(JSONAPI::Realizer.configuration.default_invalid_accept_type_exception)
36
19
  end
37
20
 
38
- private def reject_missing_type_property
39
- reject_invalid_root_property
40
-
41
- return if request.parameters.fetch("data").is_a?(Hash) && request.parameters.fetch("data").key?("type")
42
- return if request.parameters.fetch("data").is_a?(Array) && request.parameters.fetch("data").all? { |data| data.key?("type") }
21
+ private def reject_missing_content_type_header
22
+ return if request.body.read.empty?
23
+ return if request.headers.key?("Content-Type")
43
24
 
44
- raise(Error::MissingDataTypeProperty)
25
+ raise(JSONAPI::Realizer.configuration.default_missing_content_type_exception)
45
26
  end
46
27
 
47
- private def reject_invalid_type_property
48
- reject_missing_type_property
28
+ private def reject_invalid_content_type_header
29
+ reject_missing_content_type_header
49
30
 
50
- return if request.parameters.fetch("data").is_a?(Hash) && request.parameters.fetch("data").fetch("type").is_a?(String) && request.parameters.fetch("data").fetch("type").present?
51
- return if request.parameters.fetch("data").is_a?(Array) && request.parameters.fetch("data").map { |data| data.fetch("type") }.all? { |type| type.is_a?(String) && type.present? }
31
+ return if request.headers.fetch("Content-Type").include?(JSONAPI::MEDIA_TYPE)
52
32
 
53
- raise(Error::InvalidDataTypeProperty)
33
+ raise(JSONAPI::Realizer.configuration.default_invalid_content_type_exception)
54
34
  end
55
35
  end
56
36
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSONAPI
4
4
  module Realizer
5
- VERSION = "6.0.0"
5
+ VERSION = "6.1.1"
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.0.0
4
+ version: 6.1.1
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-08-30 00:00:00.000000000 Z
11
+ date: 2023-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -88,7 +88,7 @@ files:
88
88
  - lib/jsonapi/realizer/resource_spec.rb
89
89
  - lib/jsonapi/realizer/version.rb
90
90
  - lib/jsonapi/realizer_spec.rb
91
- homepage: http://krainboltgreene.github.io/jsonapi-realizer.rb
91
+ homepage: https://github.com/krainboltgreene/jsonapi-realizer.rb
92
92
  licenses:
93
93
  - HL3
94
94
  metadata: