kitty_policy 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -3
- data/lib/kitty_policy/graphql/field_authorization.rb +24 -12
- data/lib/kitty_policy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8675ef33087573ac4e48e855adeaf5aa1bff65768ef55ed7deda86744d8c0c21
|
4
|
+
data.tar.gz: 97f3bde8f761bc6a849b32696e4a4fdfdc1a454c015a96c8d6c0d22f9957d397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9e0f3c4f1e25608ca8dac48055b748aadffc66ec04f1b44e54525de9ff209214f3cd75a74ef7a29c1fc86149d35e4dde73c1d8d416f5783d94f1af3a5a044d4
|
7
|
+
data.tar.gz: f2b6e5a6f51446ff592ee0bd2fe19eb18e07a798b6d553daeb8db03f6f0b3f1e38da307db3ecee01cc1e33524901084726729dfbed806df53b1804f7b68fe688
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# KittyPolicy
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
[](https://codeclimate.com/github/producthunt/kitty-policy)
|
3
|
+
[](https://badge.fury.io/rb/kitty_policy)
|
6
4
|
[](http://travis-ci.org/producthunt/kitty-policy)
|
5
|
+
[](https://codeclimate.com/github/producthunt/kitty-policy)
|
7
6
|
|
8
7
|
Minimalistic authorization library extracted from [Product Hunt](https://www.producthunt.com/).
|
9
8
|
|
@@ -1,17 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
if defined?(::GraphQL::Field)
|
4
|
-
::GraphQL::Field.accepts_definitions(
|
5
|
-
fallback: GraphQL::Define.assign_metadata_key(:fallback),
|
6
|
-
authorize: GraphQL::Define.assign_metadata_key(:authorize),
|
7
|
-
)
|
8
|
-
end
|
9
|
-
|
10
|
-
if defined?(::GraphQL::Schema::Field)
|
11
|
-
::GraphQL::Schema::Field.accepts_definition(:fallback)
|
12
|
-
::GraphQL::Schema::Field.accepts_definition(:authorize)
|
13
|
-
end
|
14
|
-
|
15
3
|
module KittyPolicy
|
16
4
|
module GraphQL
|
17
5
|
class FieldAuthorization
|
@@ -42,5 +30,29 @@ module KittyPolicy
|
|
42
30
|
end
|
43
31
|
end
|
44
32
|
end
|
33
|
+
|
34
|
+
class AssignFallbackKey
|
35
|
+
def initialize(key)
|
36
|
+
@key = key
|
37
|
+
end
|
38
|
+
|
39
|
+
# NOTE(rstankov): This is needed because when we have empty array([]) as fallback
|
40
|
+
# internally graphql-ruby does a *args and this loses the empty array
|
41
|
+
def call(defn, value = [])
|
42
|
+
defn.metadata[@key] = value
|
43
|
+
end
|
44
|
+
end
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
if defined?(::GraphQL::Field)
|
49
|
+
::GraphQL::Field.accepts_definitions(
|
50
|
+
fallback: KittyPolicy::GraphQL::AssignFallbackKey.new(:fallback),
|
51
|
+
authorize: GraphQL::Define.assign_metadata_key(:authorize),
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
if defined?(::GraphQL::Schema::Field)
|
56
|
+
::GraphQL::Schema::Field.accepts_definition(:fallback)
|
57
|
+
::GraphQL::Schema::Field.accepts_definition(:authorize)
|
58
|
+
end
|
data/lib/kitty_policy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitty_policy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radoslav Stankov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|