api-blocks 0.4.2 → 0.4.3

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: 8234f3255752ba4fcf458c4f2c4db40bb30f44e954d4e52f6b73f8f6177febf6
4
- data.tar.gz: 47cefbcbb7ef44b7ea8759e965f3dae7dae2b60738a125c746c0bb8a51e474f4
3
+ metadata.gz: 71a94ae91f91b668d8be3d5b5317a9d72124e86e67fc1dd9f3d644a2325ca53e
4
+ data.tar.gz: 575a294250ee9c73f16d17d3c8d571af360cde384af11761dadc740d17ba45c8
5
5
  SHA512:
6
- metadata.gz: c9c51728f642fca5c4d7bcc96528a3ce35cfce6c813fb21b27a31cc9d2dfc233f52099fe968c45b3f6d7b647f556a4ae27b6329ade077c6d97b4025b98a05e80
7
- data.tar.gz: 4615a045ca9f03406f8c53a306cced6a84d04d83ada1426270dc758a174c807212321c68a2cf5664148fa9888dc159e4e742284a3d46add59959e1005188d3f9
6
+ metadata.gz: f98d59370e11d0a66db46e6cc202a0027530071f6a70e2636605fd18dc59789a695835885d3f412ff74a0a79f35d540e7938189fc2b301d9df834687190d65a0
7
+ data.tar.gz: 7d4afc732ad1bf08f5bf6694a66d49284e146f7e30c7e79cf81502f7570d3129a28c6ecd576b56f8df035e0815bf47ae6a06f88b369feaf22a45e3af0ca6f7fb
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # frozen_string_litreal: true
4
2
 
5
3
  require 'pundit'
@@ -37,20 +35,24 @@ module ApiBlocks::Controller
37
35
  # Override policy_scope to lookup pundit policies under the `scope`
38
36
  # namespace
39
37
  def policy_scope(scope)
40
- super(self.class.pundit_api_scope + [scope])
38
+ api_scope = self.class.pundit_api_scope || []
39
+
40
+ super(api_scope + [scope])
41
41
  end
42
42
 
43
43
  # Override authorize to lookup pundit policies under the `scope`
44
44
  # namespace
45
45
  def authorize(record, query = nil)
46
- super(self.class.pundit_api_scope + [record], query)
46
+ api_scope = self.class.pundit_api_scope || []
47
+
48
+ super(api_scope + [record], query)
47
49
  end
48
50
 
49
51
  handle_api_error Pundit::NotAuthorizedError do |error|
50
52
  [{ detail: error.message }, :forbidden]
51
53
  end
52
54
 
53
- mattr_accessor :pundit_api_scope, default: []
55
+ thread_mattr_accessor :pundit_api_scope
54
56
  end
55
57
 
56
58
  class_methods do
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ApiBlocks
4
4
  # Current version of ApiBlocks
5
- VERSION = '0.4.2'
5
+ VERSION = '0.4.3'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul d'Hubert