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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3793dceedf42613f23ddee1725e14f152c97d6ce
4
- data.tar.gz: 933deb25ee6be913c2013a277922262cef53d325
3
+ metadata.gz: 2b4dabf5aeb1e2ffff27e3e81aaf2de9d07cd3ad
4
+ data.tar.gz: ac91baa3d9dffb55a1e4676fa7410918a8c24ad6
5
5
  SHA512:
6
- metadata.gz: 5c467add607bc1afadb2ff9ab5c3eb46293fa33752b5b29a35c8d90c65bb3749e80e5187535d7daaeb50fdcb2e89a4fd8f17f7d83a5654c9697943cac8cfa561
7
- data.tar.gz: e1ff86425b84a98621ce3563c81e34ffdd885c9edbf3d074d10bdaadc40e569d6ba935ecd8f8f21fa45098e25137b0044b77558a23c61f570e17be8816f3a2e6
6
+ metadata.gz: b27c59f38d53bf0ca92e93cf251be87758369a9c4a7fac54d651c82e13a67d72d04bc3a7062ba15cccc82ded4e782f3314268c178f74496f6a57d46558145290
7
+ data.tar.gz: 8f9b4bc200b035080365582e9ac5668e655a9c9ab5e10e0feba6e148a9b7a2c8698ae4ea4fe259124b0f629aec9a4bd5462e40b1bab724a5db13e35f54f7ec7a
@@ -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
- super "Access denied [#{user} -> #{permission}]"
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
 
@@ -1,5 +1,5 @@
1
1
  module Rasti
2
2
  class App
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
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.5
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-05 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inflecto