clean-policy 0.3.1 → 0.3.2

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: c52178a93af24dbc3829a8e972a1185269fd9a2c6b7ff008d1a1ce426e3f5a87
4
- data.tar.gz: 80bacbfd42085a5f06cf4ed2c66aa9d8a603924f510ccd1a3841495a5ca38e17
3
+ metadata.gz: 28340ced5f43586f0f3b411558906f9aa3a11c94c643a8ca7b8c811b621c223a
4
+ data.tar.gz: e37c4d8962d5dcec670a5bf27054d1655fa30003ee719f31584bc62826718221
5
5
  SHA512:
6
- metadata.gz: 9542c98fa7de7dfc648a1e8642aed26dfd8b78bcf64c75ef8c46c5a51f0f5a7c600a7598c7f330d03abc510b33a7735d562bfafe64cce344883bababbf4170ba
7
- data.tar.gz: ab6ba29cc8581c2f499676c5f75269955c76e00d2a12e39183d9b28a4ddd03655377ad15ec354925bbb0d86d12c4f165bbafc2fa7985461a3978d19e399d3343
6
+ metadata.gz: a751da558c8c633ad93b62223eefda6c93bc80e33665fb64b8fc6132b2f8044b93ee6f9b7bdc4490a0ddfe85db809b5316cf735f849769790a4ee7fea3579cfb
7
+ data.tar.gz: 5bbb0f7c588196dddb01f975cc92e25daa4557ee3a932a70ab81886400f42dbda4d1d48b2a8c2d7fd4681b68d1bb7212cdcd736087b2ee57b294ad97b8e6bfdd
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -40,7 +40,12 @@ if klass
40
40
  end
41
41
 
42
42
  def is_authorized?
43
- !!@_is_policy_authorized
43
+ @_is_policy_authorized == true
44
+ end
45
+
46
+ def is_authorized!
47
+ raise ::Policy::Error.new('Request is not authorized!') unless is_authorized?
48
+ true
44
49
  end
45
50
  end
46
51
  end
@@ -1,9 +1,7 @@
1
1
  class Policy
2
2
  module ModelAdapter
3
- extend self
4
-
5
- def can user=nil, model=nil
6
- klass = "#{self.class}Policy"
3
+ def self.can user, model
4
+ klass = '%sPolicy' % model.class
7
5
  klass = Object.const_defined?(klass) ? klass.constantize : ModelPolicy
8
6
  Policy(model: model || self, user: user, class: klass)
9
7
  end
@@ -62,6 +62,8 @@ class Policy
62
62
  User.current
63
63
  elsif defined?(Current) && Current.respond_to?(:user)
64
64
  Current.user
65
+ else
66
+ raise RuntimeError.new('Current user not found in Policy#current_user')
65
67
  end
66
68
  end
67
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clean-policy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-15 00:00:00.000000000 Z
11
+ date: 2020-03-01 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