graphql-pundit 0.5.0 → 0.5.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
  SHA1:
3
- metadata.gz: a644c29c51d4a66d193bc9417a85b22b9573c495
4
- data.tar.gz: c913a8f1fe165bf091dbc3a20dfd29074a237601
3
+ metadata.gz: 2c8cfdd5652e733a3ccf9160bd6671d6f4e4936a
4
+ data.tar.gz: c0ca0b99379ec209201fa08ed543517f031dd8ff
5
5
  SHA512:
6
- metadata.gz: 9ab7475fa807ec3ac98123d462a2e86894fdd3f3c10f0d4bd90e1de668ec74c73b97026e1fd8b6a8a12f9ca0afbcee75b95891acae9382713b0a32bbc3ee0b7a
7
- data.tar.gz: f062e98925ee41433ef60d6d04ed660109d07dbcf806489d020ac9c0481200f9822ef58305d82306d2677e5ded5573726c4351705276bcd78374f8c6eb0a7a77
6
+ metadata.gz: 2764f622ac9f231d910550114cc6706fbba50c324ad07aea103d01916c281928ba7035691804bfc3b1431877aa188cec94ddb3287ce45bd6f39364b31d1eded0
7
+ data.tar.gz: c7c685e2e16c836039afebafad18edd91896756766fd6b67584bdf608162a7b5994de573b4be48326f0ef685dfdf61b823c2f5a080fb1ba2131e9025523ba2f3
@@ -19,11 +19,12 @@ module GraphQL
19
19
  raise ArgumentError, 'Invalid value passed to `scope`'
20
20
  end
21
21
 
22
- @scope = new_scope(scope)
22
+ @scope = scope
23
23
  end
24
24
 
25
25
  def call(root, arguments, context)
26
- new_scope = scope.call(root, arguments, context)
26
+ scope_proc = new_scope(scope)
27
+ new_scope = scope_proc.call(root, arguments, context)
27
28
  old_resolver.call(new_scope, arguments, context)
28
29
  end
29
30
 
@@ -33,11 +34,23 @@ module GraphQL
33
34
  return scope if proc?(scope)
34
35
 
35
36
  lambda do |root, _arguments, context|
36
- unless inferred?(scope)
37
- root.define_singleton_method(:policy_class) { scope }
38
- end
37
+ scope = find_scope(root, scope)
38
+ scope.new(context[current_user], root).resolve
39
+ end
40
+ end
39
41
 
40
- ::Pundit.policy_scope!(context[current_user], root)
42
+ def find_scope(root, scope)
43
+ if !inferred?(scope)
44
+ scope::Scope
45
+ else
46
+ # Special case for Sequel datasets that do not respond to
47
+ # ActiveModel's model_name
48
+ infer_from = if root.respond_to?(:model)
49
+ root.model
50
+ else
51
+ root
52
+ end
53
+ ::Pundit::PolicyFinder.new(infer_from).scope!
41
54
  end
42
55
  end
43
56
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Pundit
5
- VERSION = '0.5.0'
5
+ VERSION = '0.5.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-pundit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ontohub Core Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql