papers_please 0.1.5 → 0.1.7

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: d8107fa501a7483009cafcfb51d09a5672fbc62b881b8752efdb65fcfa559383
4
- data.tar.gz: 6059429b9c9b8465ca349762798b04a639d386a0a260c441706e69e36cf7d5e7
3
+ metadata.gz: 2e30c2562c1d819ca2e79a1ef7acaccb2372c24bc39c4725f352e3b5275d7e41
4
+ data.tar.gz: 6197ba295f65d24c4d62219de2ee4533474639978b5a78ecc83b4bfcd67b2daa
5
5
  SHA512:
6
- metadata.gz: 8f52cdec93ad99933c4a940d64e10c9912ec2d9f9a3f25a39fa0a3d9b56ab770957204752dc68a1aed1938dc4b9968158968ac74bf35a7ccaf64e2b8e9664d0c
7
- data.tar.gz: 7c116ec7dbb9a4193cccfa1649163c37020ea7a13a71414f15989a8ea71589739651bd08ee55c5a9f60b5b4341bf32666fc21a806b5aee9a28622db871ade35d
6
+ metadata.gz: 1ffe287807f012f1d2b3af3f8e079f54102d94b6e038e87fd3397a28deca0a54a9b25b84e905c9503f9553263daaa6981555ac39856c09aa0f57d7388852e832
7
+ data.tar.gz: 3efd8c9d4950d7e61fa834d52b61589e4af00e68816b416e93b591665c1bda09373c1dc510efdad8b83c24bb3aedd969f58890f2e18e99023981b5733a23794f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- papers_please (0.1.5)
4
+ papers_please (0.1.7)
5
5
  terminal-table
6
6
 
7
7
  GEM
@@ -8,6 +8,7 @@ module PapersPlease
8
8
 
9
9
  def initialize(user)
10
10
  @user = user
11
+ @default_scope = nil
11
12
  @roles = {}
12
13
  @cache = {}
13
14
 
@@ -18,6 +19,10 @@ module PapersPlease
18
19
  @fallthrough = true
19
20
  end
20
21
 
22
+ def default_scope(scope)
23
+ @default_scope = scope
24
+ end
25
+
21
26
  def configure
22
27
  raise NotImplementedError, 'The #configure method of the access policy was not implemented'
23
28
  end
@@ -81,8 +86,9 @@ module PapersPlease
81
86
  end
82
87
 
83
88
  def roles_that_can(action, subject)
84
- applicable_roles.reject do |_, role|
85
- role.find_permission(action, subject).nil?
89
+ applicable_roles.filter do |_, role|
90
+ permission = role.find_permission(action, subject)
91
+ permission&.granted?(user, subject, action) || false
86
92
  end.keys
87
93
  end
88
94
 
@@ -100,7 +106,7 @@ module PapersPlease
100
106
  return scope
101
107
  end
102
108
 
103
- nil
109
+ @default_scope || nil
104
110
  end
105
111
  alias query scope_for
106
112
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PapersPlease
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.7'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papers_please
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apsis Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-03 00:00:00.000000000 Z
11
+ date: 2023-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: terminal-table
@@ -134,7 +134,6 @@ files:
134
134
  - ".gitignore"
135
135
  - ".rspec"
136
136
  - ".rubocop.yml"
137
- - ".travis.yml"
138
137
  - Gemfile
139
138
  - Gemfile.lock
140
139
  - LICENSE.txt
@@ -171,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
170
  - !ruby/object:Gem::Version
172
171
  version: '0'
173
172
  requirements: []
174
- rubygems_version: 3.2.3
173
+ rubygems_version: 3.0.3.1
175
174
  signing_key:
176
175
  specification_version: 4
177
176
  summary: A roles & permissions gem for ruby applications.
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.2
5
- before_install: gem install bundler -v 1.16.1