egoist 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a44e3f68f8f1f3e96d0dfff72d58978e17f4b6dddbd0abcece9e8f2120aa6e8b
4
- data.tar.gz: 4363ca7c24aef5f39066ad0e70d060a26df5c87e5af7f848317fba87e9d2e736
3
+ metadata.gz: ff4a1a1d79b90a2b718a5141169ac2b676da743e890a62b87c1d7ce6b06910de
4
+ data.tar.gz: 6593f07607c1cc1a4edf014cd0d564e1b03b610ad7f061d0d346c8102e4eeb4b
5
5
  SHA512:
6
- metadata.gz: 87725d7d4b8510cd8e4193df17c782a9a2d6cd252a2a54c973f8a78adcbcd8039ed798df893b56940b01cfdf56dc413b89eec8f6823f5cbadb0bee3522cb00ad
7
- data.tar.gz: eb395431b15ef13eab8e8f7a732334a0e8dba87f1f48344c58967aded2336f96a159f0d069ec098fa12df940baa12e71fb3033137d4ce4ecac283bd13e34b338
6
+ metadata.gz: 63ee19f4ed570d9ba2765c20c71939acdf99974214435ef1b816f413dfd8735af70222daf56e5cf2dd8aac70c97303866d7c777d7477092079e5aac64324eb3d
7
+ data.tar.gz: 951f18456159d1ef8e1c1d8b88f26b2c177bd7735b361bac287e7431b4b3a3c0b224530f3864d370b72f2b2c795309bc63ea2036c2e10a176f48cddd3c3af830
data/.version CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.9.1
@@ -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,15 +42,19 @@ 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
- if block_given?
48
- yield error
49
- nil
50
- elsif action == '!'
51
- raise error
52
+ msg = yield error if block_given?
53
+
54
+ if action == '!'
55
+ raise msg ? Policy::Error.new(msg) : error
52
56
  elsif action == '?'
53
- nil
57
+ false
54
58
  else
55
59
  raise ArgumentError.new('Bad policy method %s' % name)
56
60
  end
metadata CHANGED
@@ -1,14 +1,13 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-06-27 00:00:00.000000000 Z
10
+ date: 2025-08-25 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Clean, simple explicit and strait-forward policy definitions.
14
13
  email: reic.dino@gmail.com
@@ -27,7 +26,6 @@ homepage: https://github.com/dux/egoist
27
26
  licenses:
28
27
  - MIT
29
28
  metadata: {}
30
- post_install_message:
31
29
  rdoc_options: []
32
30
  require_paths:
33
31
  - lib
@@ -42,8 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
40
  - !ruby/object:Gem::Version
43
41
  version: '0'
44
42
  requirements: []
45
- rubygems_version: 3.2.3
46
- signing_key:
43
+ rubygems_version: 3.6.6
47
44
  specification_version: 4
48
45
  summary: Ruby access policy library
49
46
  test_files: []