authoraise 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/README.md +11 -2
- data/lib/authoraise.rb +6 -1
- data/lib/authoraise/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2c271c2600e3068fc07db2fa9a0ebabd15a8088
|
4
|
+
data.tar.gz: 1e193de6d04c36fa53bec146e30eccbb61cb56b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c21be062fa9d96ba1af1c5a7ef9298ff10e81f452c58cec35709f656bf9b3779b87f3433abcb59ca80b5fc082fc9f365ca2fec7d3fba1bbe27124807e876c2
|
7
|
+
data.tar.gz: 6e4612975dd9be0c865e5266087367c6d3ca2202f0105f6315de5692051a164e5c0067cb5fa1c7dd58cf2adfe8126ffc7bf5cfe72d6763547e83a9474c8bcf9a
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ So instead of writing boolean expressions like this.
|
|
6
6
|
|
7
7
|
~~~ruby
|
8
8
|
options[:post] &&
|
9
|
-
(options[:post].
|
9
|
+
(options[:post].published? || (options[:post].user == options[:user]))
|
10
10
|
~~~
|
11
11
|
|
12
12
|
You would write them like this.
|
@@ -18,7 +18,16 @@ You would write them like this.
|
|
18
18
|
policy.authorize(options)
|
19
19
|
~~~
|
20
20
|
|
21
|
-
Or like this.
|
21
|
+
Or like this (my personal favorite).
|
22
|
+
|
23
|
+
~~~ruby
|
24
|
+
policy = Authoraise::Policy.new do |p|
|
25
|
+
p.allow { |post| post.published? }
|
26
|
+
p.allow { |post, user| post.user == user }
|
27
|
+
end
|
28
|
+
~~~
|
29
|
+
|
30
|
+
Or like this, where declaration and authorization both happen inline.
|
22
31
|
|
23
32
|
~~~ruby
|
24
33
|
authorize(options) do |policy|
|
data/lib/authoraise.rb
CHANGED
@@ -14,7 +14,7 @@ module Authoraise
|
|
14
14
|
attr_reader :required_keys
|
15
15
|
|
16
16
|
def initialize(required_keys, procedure)
|
17
|
-
@required_keys = required_keys.to_set
|
17
|
+
@required_keys = required_keys.to_set.freeze
|
18
18
|
@procedure = procedure
|
19
19
|
end
|
20
20
|
|
@@ -66,6 +66,11 @@ module Authoraise
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def freeze
|
70
|
+
@checks.freeze
|
71
|
+
super
|
72
|
+
end
|
73
|
+
|
69
74
|
private
|
70
75
|
|
71
76
|
def assert_all_keys_match(given_keys)
|
data/lib/authoraise/version.rb
CHANGED