jsonapi-authorization 1.0.0.alpha4 → 1.0.0.alpha5

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: 994dbbd65ed5c9b5d65b3addc2bf880dbdd0b102
4
- data.tar.gz: 9cb8b76e4f5f2105f79239a3c5493957b13511e4
3
+ metadata.gz: 38df18640b26a88119c4c253745a5b78bf549f16
4
+ data.tar.gz: 1e3676e726ba546d80ed364d1a16673a2c78ebd2
5
5
  SHA512:
6
- metadata.gz: c6230923d4150aa1a207f64ca473f3cf147644729c8449a353bbdd9b85b2db319232388bec7ba7f57c379311cea0c8a0c5cd3b8bd4aa4ab438525ffbd6e7d20a
7
- data.tar.gz: 63ea830d6a7a9b6a635f493027a2f2ce2441e79b77c39869b5175598b461ae7370f4e0bc280e0666fd55a275a96a92c09ccff40eaf55b4f6af905e10b9f5c630
6
+ metadata.gz: 41b360cfcee0708244121f9b1debea24e1414776c89346b7ede2e57c0b2e1178a0587f39a838ca8b2641e555c529cbbdc0f9505467aa30dfd022bc62f1a07422
7
+ data.tar.gz: c0ba742a117a18b2273ed7662187d70a65e404f3c09b1bb48e37801ebbe7396ba39dd1348508e6ecee7b0a14dfd7ddbd1639f7e73afcbab7b84ca2d1f5bb974a
@@ -237,10 +237,15 @@ module JSONAPI
237
237
 
238
238
  private
239
239
 
240
- def authorize_relationship_operation(source_record, relationship_method, *args)
240
+ def authorize_relationship_operation(
241
+ source_record,
242
+ relationship_method,
243
+ related_record_or_records = nil
244
+ )
241
245
  policy = ::Pundit.policy(user, source_record)
242
246
  if policy.respond_to?(relationship_method)
243
- unless policy.public_send(relationship_method, *args)
247
+ args = [relationship_method, related_record_or_records].reject(&:nil?)
248
+ unless policy.public_send(*args)
244
249
  raise ::Pundit::NotAuthorizedError,
245
250
  query: relationship_method,
246
251
  record: source_record,
@@ -248,6 +253,11 @@ module JSONAPI
248
253
  end
249
254
  else
250
255
  ::Pundit.authorize(user, source_record, 'update?')
256
+ if related_record_or_records
257
+ Array(related_record_or_records).each do |related_record|
258
+ ::Pundit.authorize(user, related_record, 'update?')
259
+ end
260
+ end
251
261
  end
252
262
  end
253
263
 
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Authorization
3
- VERSION = "1.0.0.alpha4".freeze
3
+ VERSION = "1.0.0.alpha5".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha4
4
+ version: 1.0.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vesa Laakso
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-30 00:00:00.000000000 Z
12
+ date: 2017-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-resources