authoraise 0.1.2 → 0.1.3

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: bad448d3d7ef8c5805470e70819ecbb6575daaa1
4
- data.tar.gz: 4e85ac9821aaa0f96a1afc490c6554512036b2b2
3
+ metadata.gz: a2c271c2600e3068fc07db2fa9a0ebabd15a8088
4
+ data.tar.gz: 1e193de6d04c36fa53bec146e30eccbb61cb56b5
5
5
  SHA512:
6
- metadata.gz: cd68a93363b33ba04674cf5a90a932eefbac6c80130842d273b8775f9357583e8030d1b200da7c298d776cb4776eb6cb32fee5d9d022fce37622a01c4688772a
7
- data.tar.gz: 6bb5bb7a4724ae819a318f276d0bd5cbe9d91dca8890cf572ec197e7eb4e1baed77f1954f2494f49023351275b62cae05ed0d97ae7bfb8a603d29c6ff14b42ef
6
+ metadata.gz: b0c21be062fa9d96ba1af1c5a7ef9298ff10e81f452c58cec35709f656bf9b3779b87f3433abcb59ca80b5fc082fc9f365ca2fec7d3fba1bbe27124807e876c2
7
+ data.tar.gz: 6e4612975dd9be0c865e5266087367c6d3ca2202f0105f6315de5692051a164e5c0067cb5fa1c7dd58cf2adfe8126ffc7bf5cfe72d6763547e83a9474c8bcf9a
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.1.3
2
+
3
+ * Make Policy#freeze actually freeze the internal checks array
4
+
1
5
  v0.1.2
2
6
 
3
7
  * Policy constructor now accepts block: policy = Policy.new{ |p| p.allow{} }
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].publised? || (options[:post].user == options[:user]))
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|
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Authoraise
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authoraise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Chernyak