walruz 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.
- data/VERSION.yml +1 -1
- data/lib/walruz/policy.rb +6 -3
- data/lib/walruz/utils.rb +4 -5
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/walruz/policy.rb
CHANGED
@@ -9,8 +9,6 @@ module Walruz
|
|
9
9
|
class Policy
|
10
10
|
extend Walruz::Utils
|
11
11
|
|
12
|
-
attr_reader :params
|
13
|
-
|
14
12
|
# @private
|
15
13
|
# :nodoc:
|
16
14
|
def self.inherited(child)
|
@@ -189,7 +187,12 @@ module Walruz
|
|
189
187
|
# :nodoc:
|
190
188
|
def set_params(params)
|
191
189
|
@params = params
|
192
|
-
|
190
|
+
self
|
191
|
+
end
|
192
|
+
|
193
|
+
def params
|
194
|
+
@params ||= {}
|
195
|
+
end
|
193
196
|
|
194
197
|
end
|
195
198
|
end
|
data/lib/walruz/utils.rb
CHANGED
@@ -41,7 +41,7 @@ module Walruz
|
|
41
41
|
def authorized?(actor, subject)
|
42
42
|
result = nil
|
43
43
|
self.class.policies.detect do |policy|
|
44
|
-
result = policy.new.safe_authorized?(actor, subject)
|
44
|
+
result = policy.new.set_params(params).safe_authorized?(actor, subject)
|
45
45
|
result[0]
|
46
46
|
end
|
47
47
|
result[0] ? result : result[0]
|
@@ -59,12 +59,10 @@ module Walruz
|
|
59
59
|
|
60
60
|
# :nodoc:
|
61
61
|
def authorized?(actor, subject)
|
62
|
-
acum = [true, {}]
|
62
|
+
acum = [true, self.params || {}]
|
63
63
|
self.class.policies.each do |policy|
|
64
64
|
break unless acum[0]
|
65
|
-
|
66
|
-
policy_instance.set_params(acum[1])
|
67
|
-
result = policy_instance.safe_authorized?(actor, subject)
|
65
|
+
result = policy.new.set_params(acum[1]).safe_authorized?(actor, subject)
|
68
66
|
acum[0] &&= result[0]
|
69
67
|
acum[1].merge!(result[1])
|
70
68
|
end
|
@@ -88,6 +86,7 @@ module Walruz
|
|
88
86
|
|
89
87
|
# :nodoc:
|
90
88
|
def authorized?(actor, subject)
|
89
|
+
self.class.policy.set_params(params)
|
91
90
|
result = self.class.policy.new.safe_authorized?(actor, subject)
|
92
91
|
!result[0]
|
93
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: walruz
|
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
|
- Roman Gonzalez
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|