simple_acl 1.0.2 → 1.0.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.
data/README.md CHANGED
@@ -2,7 +2,18 @@
2
2
 
3
3
  This gem eases the implementation of ACL in Ruby (especially Rails).
4
4
 
5
- All access are refused : the only default rule.
5
+ You should be able to use it everywhere you can execute the `do_acl` method before any protected methods.
6
+
7
+ All access are refused is the only default rule.
8
+
9
+ ## Use case
10
+
11
+ For example, you're building a powerful API with multiple models behind one RESTful controller.
12
+
13
+ In this case the ressource accessed is not the model but the controller. That's why ACL should be defined at
14
+ controller level in this case.
15
+
16
+ SimpleAcl's goal is to be a perfect tool to perform ACL at this level.
6
17
 
7
18
  ## Installation
8
19
 
@@ -14,9 +25,9 @@ And then execute:
14
25
 
15
26
  $ bundle install
16
27
 
17
- ## Usage
28
+ ## Usage with Ruby on Rails
18
29
 
19
- Include the main module:
30
+ Include the main module in your controller:
20
31
 
21
32
  `include SimpleAcl`
22
33
 
@@ -39,7 +50,7 @@ execution of the code in the action.
39
50
 
40
51
  When the access is refused to a given role, an `ExceptionUnauthorized`
41
52
  exception will be raised.
42
- Catch it to render/do whatever you want in this case (exemple with Rails):
53
+ Catch it to render/do whatever you want in this case (example with Rails):
43
54
 
44
55
  ```ruby
45
56
  rescue_from ExceptionUnauthorized do
@@ -86,8 +97,7 @@ An assertion has to return `TrueClass` or `FalseClass`.
86
97
  (other values will have same effect than a `FalseClass`)
87
98
 
88
99
  You can also use lambda to write advanced assertion.
89
- The two parameters `current_role` and `values` are passed to the lambda,
90
- you can use these for your assertion.
100
+ You can use the variable `values` to the lambda.
91
101
 
92
102
  Example:
93
103
 
@@ -9,6 +9,10 @@ module SimpleAcl
9
9
  @configuration = Configuration.new
10
10
  end
11
11
 
12
+ def get_acl(action)
13
+ configuration.acl_privileges.keys.select{|k| configuration.acl_privileges[k][action] }
14
+ end
15
+
12
16
  def check_acl(current_role, action, values)
13
17
 
14
18
  return self.class.unauthorized unless configuration && current_role
@@ -1,3 +1,3 @@
1
1
  module SimpleAcl
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_acl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-17 00:00:00.000000000 Z
12
+ date: 2014-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -41,7 +41,8 @@ files:
41
41
  - lib/simple_acl/exceptions.rb
42
42
  - lib/simple_acl.rb
43
43
  homepage: https://github.com/ifeelgoods/simple_acl
44
- licenses: []
44
+ licenses:
45
+ - Apache License Version 2.0
45
46
  post_install_message:
46
47
  rdoc_options: []
47
48
  require_paths:
@@ -60,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
61
  version: '0'
61
62
  requirements: []
62
63
  rubyforge_project:
63
- rubygems_version: 1.8.25
64
+ rubygems_version: 1.8.23
64
65
  signing_key:
65
66
  specification_version: 3
66
67
  summary: Simple gem to implement ACL in Ruby (especially in Rails).