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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a44e3f68f8f1f3e96d0dfff72d58978e17f4b6dddbd0abcece9e8f2120aa6e8b
4
- data.tar.gz: 4363ca7c24aef5f39066ad0e70d060a26df5c87e5af7f848317fba87e9d2e736
3
+ metadata.gz: b6bd4a8956152dd8b62d79b7649ef0068c0ec77c8fa4f4a32fbfe6d045ecdc00
4
+ data.tar.gz: cc0ba2348f4802a38e5a8443b49f199f1e270155ba25bb92f61aef12db160619
5
5
  SHA512:
6
- metadata.gz: 87725d7d4b8510cd8e4193df17c782a9a2d6cd252a2a54c973f8a78adcbcd8039ed798df893b56940b01cfdf56dc413b89eec8f6823f5cbadb0bee3522cb00ad
7
- data.tar.gz: eb395431b15ef13eab8e8f7a732334a0e8dba87f1f48344c58967aded2336f96a159f0d069ec098fa12df940baa12e71fb3033137d4ce4ecac283bd13e34b338
6
+ metadata.gz: 2309402638c0d1be1aef9308102a8188d0fc70c20fc342ea6a2bc66208845766032a26e8de3ce8c00fc6da93dfda01dbad4e5784e87cb726677558a17c010efc
7
+ data.tar.gz: d2f54296ac9f21bd77710857e8e1ae5871708a177fa5b17ac5e9b9f906971631dcff856d470a629a967e918a577ff02b908e2e8b7e92f2607c51f739003c81ea
data/.version CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.9.0
@@ -1,13 +1,8 @@
1
- klass =
2
- if defined? Rails
3
- ActionController::Base
4
- elsif defined? Lux
5
- Lux::Controller
6
- end
1
+ # include Policy::Controller
7
2
 
8
- if klass
9
- klass.class_eval do
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
@@ -1,14 +1,9 @@
1
- klass =
2
- if defined? ActiveRecord
3
- ActiveRecord::Base
4
- elsif defined? Sequel
5
- Sequel::Model
6
- end
1
+ # include Policy::Model
7
2
 
8
- if klass
9
- klass.class_eval do
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
- @policy.model || true
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
- nil
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.8.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-06-27 00:00:00.000000000 Z
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