porteiro 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: b77cc84a577a1df25f973f6bda15683bf29cbe12
4
- data.tar.gz: cacbfc99a998376384e8d0a11576db479c7eee30
3
+ metadata.gz: cc1abca76118ff41f97227c06ca84665ca56122a
4
+ data.tar.gz: 25098d250e680c167c5366e4dd0009699db1cde4
5
5
  SHA512:
6
- metadata.gz: 7fe16b33a0880c7fc182a15e2a1b71cbfdd048d59264b1142c18a729054fce5c93aa4ab5cc05fcfbec8b6a21ada45dc143580c13e3125c219afd35185c9d8195
7
- data.tar.gz: c7243128339a02a3e2a491f4c9eeb59eff5bfd543927c6269d2adaf214eb039f0ccbf8d2856e5fdfe6916914b65f8fcafddb44bcf2a8b4d691a77b00290f9517
6
+ metadata.gz: 5e549c7fe34b7a86fcd4676e0a698add91d0ed0cfaf3683e584bacc73e52f95b6f37fbe6930e51f33f3d6b9d061aef3500a09134b04b8fbe392d690dde529385
7
+ data.tar.gz: 12bd5b44d549b2349b4a43201e9c98524ddcc8149040d0cc9a23ab6495af9d1e6e83d39c11b8cb1e2e518744f77400906e085debb1b89cff8adb09ce231b1d15
data/lib/porteiro.rb CHANGED
@@ -9,7 +9,7 @@ module Porteiro
9
9
 
10
10
  class NotAuthorizedError < StandardError;end
11
11
  class PolicyUndefinedError < StandardError;end
12
-
12
+ class AuthorizationNotPerformedError < StandardError;end
13
13
 
14
14
  class << self
15
15
 
@@ -40,11 +40,16 @@ module Porteiro
40
40
  ##
41
41
 
42
42
  def authorize_user_access!
43
+ @_policy_authorized = true
43
44
  policy_obj = policy
44
45
  controller_action = policy_obj.params.fetch(:action)
45
46
  policy_obj.send("#{controller_action}?") ? true : (raise NotAuthorizedError, "You aren't permitted to access this resource")
46
47
  end
47
48
 
49
+ def verify_authorized
50
+ raise AuthorizationNotPerformedError unless @_policy_authorized
51
+ end
52
+
48
53
  def policy
49
54
  @policy || Porteiro.policy(porteiro_user, params)
50
55
  end
@@ -1,3 +1,3 @@
1
1
  module Porteiro
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: porteiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bradwheel