porteiro 0.0.1 → 0.0.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 +4 -4
- data/lib/porteiro/base.rb +1 -6
- data/lib/porteiro/version.rb +1 -1
- data/lib/porteiro.rb +3 -1
- data/spec/porteiro_spec.rb +0 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b77cc84a577a1df25f973f6bda15683bf29cbe12
|
|
4
|
+
data.tar.gz: cacbfc99a998376384e8d0a11576db479c7eee30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7fe16b33a0880c7fc182a15e2a1b71cbfdd048d59264b1142c18a729054fce5c93aa4ab5cc05fcfbec8b6a21ada45dc143580c13e3125c219afd35185c9d8195
|
|
7
|
+
data.tar.gz: c7243128339a02a3e2a491f4c9eeb59eff5bfd543927c6269d2adaf214eb039f0ccbf8d2856e5fdfe6916914b65f8fcafddb44bcf2a8b4d691a77b00290f9517
|
data/lib/porteiro/base.rb
CHANGED
|
@@ -6,11 +6,6 @@ module Porteiro
|
|
|
6
6
|
@params = params
|
|
7
7
|
end
|
|
8
8
|
attr_reader :user, :params
|
|
9
|
-
|
|
10
|
-
def authorize_action!
|
|
11
|
-
controller_action = params.fetch(:action)
|
|
12
|
-
self.send("#{controller_action}?") ? true : (raise NotAuthorizedError, "You aren't permitted to access this resource")
|
|
13
|
-
end
|
|
14
|
-
|
|
9
|
+
|
|
15
10
|
end
|
|
16
11
|
end
|
data/lib/porteiro/version.rb
CHANGED
data/lib/porteiro.rb
CHANGED
|
@@ -40,7 +40,9 @@ module Porteiro
|
|
|
40
40
|
##
|
|
41
41
|
|
|
42
42
|
def authorize_user_access!
|
|
43
|
-
policy
|
|
43
|
+
policy_obj = policy
|
|
44
|
+
controller_action = policy_obj.params.fetch(:action)
|
|
45
|
+
policy_obj.send("#{controller_action}?") ? true : (raise NotAuthorizedError, "You aren't permitted to access this resource")
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
def policy
|
data/spec/porteiro_spec.rb
CHANGED
|
@@ -99,11 +99,6 @@ describe Porteiro do
|
|
|
99
99
|
expect(policy.params).to eq controller.params
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
it "#authorize_action!" do
|
|
103
|
-
policy = Porteiro::PolicyFinder.new(controller.current_user, controller.params).find!
|
|
104
|
-
expect(policy.authorize_action!).to eq true
|
|
105
|
-
end
|
|
106
|
-
|
|
107
102
|
end
|
|
108
103
|
|
|
109
104
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: porteiro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- bradwheel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-05-
|
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|