egoist 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/lib/adapters/controller.rb +4 -9
- data/lib/adapters/model.rb +5 -10
- data/lib/egoist/proxy.rb +7 -2
- 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: b6bd4a8956152dd8b62d79b7649ef0068c0ec77c8fa4f4a32fbfe6d045ecdc00
|
4
|
+
data.tar.gz: cc0ba2348f4802a38e5a8443b49f199f1e270155ba25bb92f61aef12db160619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2309402638c0d1be1aef9308102a8188d0fc70c20fc342ea6a2bc66208845766032a26e8de3ce8c00fc6da93dfda01dbad4e5784e87cb726677558a17c010efc
|
7
|
+
data.tar.gz: d2f54296ac9f21bd77710857e8e1ae5871708a177fa5b17ac5e9b9f906971631dcff856d470a629a967e918a577ff02b908e2e8b7e92f2607c51f739003c81ea
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/lib/adapters/controller.rb
CHANGED
@@ -1,13 +1,8 @@
|
|
1
|
-
|
2
|
-
if defined? Rails
|
3
|
-
ActionController::Base
|
4
|
-
elsif defined? Lux
|
5
|
-
Lux::Controller
|
6
|
-
end
|
1
|
+
# include Policy::Controller
|
7
2
|
|
8
|
-
|
9
|
-
|
10
|
-
def authorize result=false
|
3
|
+
class Policy
|
4
|
+
module Controller
|
5
|
+
def authorize result = false
|
11
6
|
if (block_given? ? yield : result)
|
12
7
|
@_is_policy_authorized = true
|
13
8
|
else
|
data/lib/adapters/model.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
|
2
|
-
if defined? ActiveRecord
|
3
|
-
ActiveRecord::Base
|
4
|
-
elsif defined? Sequel
|
5
|
-
Sequel::Model
|
6
|
-
end
|
1
|
+
# include Policy::Model
|
7
2
|
|
8
|
-
|
9
|
-
|
10
|
-
def can user=nil
|
11
|
-
Policy.can self, user
|
3
|
+
class Policy
|
4
|
+
module Model
|
5
|
+
def can user = nil
|
6
|
+
Policy.can model: self, user: user
|
12
7
|
end
|
13
8
|
end
|
14
9
|
end
|
data/lib/egoist/proxy.rb
CHANGED
@@ -42,7 +42,12 @@ class Policy
|
|
42
42
|
action = $1
|
43
43
|
|
44
44
|
@policy.can?(name, *args)
|
45
|
-
|
45
|
+
|
46
|
+
if action == '!'
|
47
|
+
@policy.model || true
|
48
|
+
else
|
49
|
+
true
|
50
|
+
end
|
46
51
|
rescue Policy::Error => error
|
47
52
|
if block_given?
|
48
53
|
yield error
|
@@ -50,7 +55,7 @@ class Policy
|
|
50
55
|
elsif action == '!'
|
51
56
|
raise error
|
52
57
|
elsif action == '?'
|
53
|
-
|
58
|
+
false
|
54
59
|
else
|
55
60
|
raise ArgumentError.new('Bad policy method %s' % name)
|
56
61
|
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.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dino Reic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-02 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
|