kitty_policy 0.1.0 → 0.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: b8f0d1d608e02d9582d87caa5eaaa996b44330dc9ac80d5127714ab83999edb1
4
- data.tar.gz: c3eae5bde27d4f36e68f27b5f9b67018df1a30b89cdf2f046bc6b15579c2db34
3
+ metadata.gz: 8675ef33087573ac4e48e855adeaf5aa1bff65768ef55ed7deda86744d8c0c21
4
+ data.tar.gz: 97f3bde8f761bc6a849b32696e4a4fdfdc1a454c015a96c8d6c0d22f9957d397
5
5
  SHA512:
6
- metadata.gz: a956131b3414441be7638c127844f8f2a92c1a523e20ef19a086a48b9846d234738f6d4efd7aeaa697b441674774daa019c793bf7933fa974be435a7044cc6d6
7
- data.tar.gz: d013ea28cfd0fa1796d12857d8ae33e9bb0015cef1da23d1254ac9462e8931ac12dbba33a41d54c619ea897d24a7b1f134d9db9a6dd115d4cca78bed633aa66a
6
+ metadata.gz: c9e0f3c4f1e25608ca8dac48055b748aadffc66ec04f1b44e54525de9ff209214f3cd75a74ef7a29c1fc86149d35e4dde73c1d8d416f5783d94f1af3a5a044d4
7
+ data.tar.gz: f2b6e5a6f51446ff592ee0bd2fe19eb18e07a798b6d553daeb8db03f6f0b3f1e38da307db3ecee01cc1e33524901084726729dfbed806df53b1804f7b68fe688
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.1.1
4
+
5
+ * **[fix]** Allow for `fallback: []` in GraphQL (@rstankov)
6
+
3
7
  ## Version 0.1
4
8
 
5
9
  * Initial release (@rstankov)
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # KittyPolicy
2
2
 
3
- **NOT RELEASED YET**
4
-
5
- [![Code Climate](https://codeclimate.com/github/producthunt/kitty-policy.svg)](https://codeclimate.com/github/producthunt/kitty-policy)
3
+ [![Gem Version](https://badge.fury.io/rb/kitty_policy.svg)](https://badge.fury.io/rb/kitty_policy)
6
4
  [![Build Status](https://secure.travis-ci.org/producthunt/kitty-policy.svg)](http://travis-ci.org/producthunt/kitty-policy)
5
+ [![Code Climate](https://codeclimate.com/github/producthunt/kitty-policy.svg)](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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KittyPolicy
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
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.0
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: 2019-07-28 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler