egoist 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/egoist/base.rb +9 -3
  4. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6b402250800b2baaa5bacd32efadb63c68a3b9364fae92523b9eb3e13bd84ef
4
- data.tar.gz: 609c7e240a70f6b33e98f1ed79c183e2a29fe466f94d49289562c905b2cb827a
3
+ metadata.gz: ea4e36f6d1468e4ef6315c36155873a1f0a55889517a7642da29f67c61305d12
4
+ data.tar.gz: cb2e309cfe453ed80a05c0409c203b584efff5f2a13aac47a83d662831f6cc8d
5
5
  SHA512:
6
- metadata.gz: db2aea02ff0afb797b5dc3b978553191e816df2e7a81019981fb04cbcc5a1530727de6bbe725c621b6c749d72d7b46f23d37aa49121ce8ecc7698fe3efffb632
7
- data.tar.gz: 677256afb6d61ba83ee3ce1f1f2cd6aebaa43b1328b1840f03a77f226d030b32d6bcac9a36c2368177f826e88eaa4fa65a643353eb8b009c74b3c1d6e4df1019
6
+ metadata.gz: 80b16f41f289bfe0de44e976838d0a7c94e134d573bfb1636ccb89438e8808794dec5c33ebdc70d60e7fe109198edd17021e04f516457e9957a9bc7c85dede15
7
+ data.tar.gz: b87b9ad5c35b61006c76d6fb4f520ae7a8e1ae9ca8e3f555f4c06a24cca72aea7f0cdce09bf4340b0de0abe6e5eedfabc7c4b09d04b806e15d6b48be62936531
data/.version CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -10,7 +10,7 @@ class Policy
10
10
  end
11
11
 
12
12
  ###
13
-
13
+
14
14
  attr_reader :model, :user, :action
15
15
 
16
16
  def initialize model:, user: nil
@@ -44,8 +44,8 @@ class Policy
44
44
  def call *args, &block
45
45
  raise Error, 'User is not defined, no access' unless @user
46
46
 
47
- return true if before(@action)
48
- return true if send(@action, *args)
47
+ return true if before(@action) == true
48
+ return true if send(@action, *args) && after(@action) == true
49
49
 
50
50
  raise Error, 'Access disabled in policy'
51
51
  rescue Policy::Error => error
@@ -64,6 +64,10 @@ class Policy
64
64
  false
65
65
  end
66
66
 
67
+ def after action
68
+ true
69
+ end
70
+
67
71
  def error message
68
72
  raise Policy::Error.new(message)
69
73
  end
@@ -74,6 +78,8 @@ class Policy
74
78
  User.current
75
79
  elsif defined?(Current) && Current.respond_to?(:user)
76
80
  Current.user
81
+ elsif user = Thread.current[:current_user]
82
+ user
77
83
  else
78
84
  raise RuntimeError.new('Current user not found in Policy#current_user')
79
85
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egoist
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
  - Dino Reic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-04 00:00:00.000000000 Z
11
+ date: 2020-09-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Clean, simple explicit and strait-forward policy definitions.
14
14
  email: reic.dino@gmail.com
@@ -28,7 +28,7 @@ homepage: https://github.com/dux/egoist
28
28
  licenses:
29
29
  - MIT
30
30
  metadata: {}
31
- post_install_message:
31
+ post_install_message:
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  version: '0'
45
45
  requirements: []
46
46
  rubygems_version: 3.0.6
47
- signing_key:
47
+ signing_key:
48
48
  specification_version: 4
49
49
  summary: Ruby access policy library
50
50
  test_files: []