rasti-app 0.0.5 → 0.0.6
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/rasti/app/policy.rb +12 -3
- data/lib/rasti/app/version.rb +1 -1
- 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: 2b4dabf5aeb1e2ffff27e3e81aaf2de9d07cd3ad
|
4
|
+
data.tar.gz: ac91baa3d9dffb55a1e4676fa7410918a8c24ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b27c59f38d53bf0ca92e93cf251be87758369a9c4a7fac54d651c82e13a67d72d04bc3a7062ba15cccc82ded4e782f3314268c178f74496f6a57d46558145290
|
7
|
+
data.tar.gz: 8f9b4bc200b035080365582e9ac5668e655a9c9ab5e10e0feba6e148a9b7a2c8698ae4ea4fe259124b0f629aec9a4bd5462e40b1bab724a5db13e35f54f7ec7a
|
data/lib/rasti/app/policy.rb
CHANGED
@@ -3,9 +3,18 @@ module Rasti
|
|
3
3
|
class Policy
|
4
4
|
|
5
5
|
class UnauthorizedError < StandardError
|
6
|
+
|
7
|
+
attr_reader :user, :permission
|
8
|
+
|
6
9
|
def initialize(user, permission)
|
7
|
-
|
10
|
+
@user = user
|
11
|
+
@permission = permission
|
12
|
+
end
|
13
|
+
|
14
|
+
def message
|
15
|
+
"Permission denied [#{user} -> #{permission}]"
|
8
16
|
end
|
17
|
+
|
9
18
|
end
|
10
19
|
|
11
20
|
class << self
|
@@ -31,7 +40,7 @@ module Rasti
|
|
31
40
|
@context = context
|
32
41
|
end
|
33
42
|
|
34
|
-
def authorized?(permission, params)
|
43
|
+
def authorized?(permission, params={})
|
35
44
|
if self.class.authorizations.key? permission
|
36
45
|
self.class.authorizations[permission].call params
|
37
46
|
else
|
@@ -39,7 +48,7 @@ module Rasti
|
|
39
48
|
end
|
40
49
|
end
|
41
50
|
|
42
|
-
def authorize!(permission, params)
|
51
|
+
def authorize!(permission, params={})
|
43
52
|
raise UnauthorizedError.new(user.name, permission) unless authorized? permission, params
|
44
53
|
end
|
45
54
|
|
data/lib/rasti/app/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasti-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflecto
|