arpa 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 +4 -4
- data/README.md +10 -2
- data/lib/arpa/controllers/resources_controller.rb +1 -1
- data/lib/arpa/entities/profile.rb +1 -1
- data/lib/arpa/services/resources/resource_manager_creator.rb +6 -4
- data/lib/arpa/version.rb +1 -1
- data/spec/lib/ar/services/resources/resource_manager_creator_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e222788d3061cf1fb09f3285f2781c7e6e595ea7
|
4
|
+
data.tar.gz: 9260e3311202810408e671555bc4e25d8bc9765e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0dc1b3734844fb94c895ece8ed933b2aea924093c441de369dd0aa17d44993619d7beaccf76ff16ca21e52a367ce5829bf250f5603869901ba458695871a14e
|
7
|
+
data.tar.gz: 7c7a9cc23e14c15f9402a67e7d80c9f2209b1cf9c097c3b5a5fc09a748b017705a9e1723d711296df030b312b0625cffcebfd70c3631f3c55825d763f658dcef
|
data/README.md
CHANGED
@@ -41,7 +41,7 @@ After generate, you need to run the migration to create all Arpa tables:
|
|
41
41
|
|
42
42
|
## Usage
|
43
43
|
|
44
|
-
First of all you must create the Resources, Roles and Profiles (each is avaliable in the paths listed
|
44
|
+
First of all you must create the Resources, Roles and Profiles (each is avaliable in the paths listed in a section bellow). After that you need associate **Profiles** with **User** (to do this, you need create by your own the associate form view, saving some profiles in some user). Done that you can use some Helpers generated by Arpa.
|
45
45
|
|
46
46
|
### Association between Profiles and Users
|
47
47
|
|
@@ -65,16 +65,24 @@ To verify if a user has access to some :controler and :action, use the following
|
|
65
65
|
```ruby
|
66
66
|
has_access?('users', 'index')
|
67
67
|
```
|
68
|
+
|
69
|
+
To reset the session permissions created by Arpa, use the following helper:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
reset_permissions
|
73
|
+
```
|
74
|
+
|
68
75
|
**Obs.:** To that helper method works. You must have **:session** (In Rails app already has) and **:current_user** attribute or method.
|
69
76
|
|
70
77
|
---
|
71
|
-
If you want use that
|
78
|
+
If you want use that methods inside another object you should use the **Arpa::Services::Verifier** class;
|
72
79
|
|
73
80
|
You just need pass as arguments the :session and :current_user:
|
74
81
|
|
75
82
|
```ruby
|
76
83
|
verifier = Arpa::Services::Verifier.new(session, current_user)
|
77
84
|
verifier.has_access?('users', 'index')
|
85
|
+
verifier.reset_permissions
|
78
86
|
```
|
79
87
|
|
80
88
|
### Controller Filter
|
@@ -17,7 +17,7 @@ module Arpa
|
|
17
17
|
def generate_resources_and_actions
|
18
18
|
Rails.application.eager_load!
|
19
19
|
|
20
|
-
resource_creator.create({resourceables: ApplicationController.descendants}, {
|
20
|
+
resource_creator.create({resourceables: ApplicationController.descendants, except_action_methods: ApplicationController.action_methods}, {
|
21
21
|
success: -> (resource) {
|
22
22
|
flash[:notice] = I18n.t('flash.actions.generate_resources_and_actions.notice')
|
23
23
|
},
|
@@ -6,13 +6,14 @@ module Arpa
|
|
6
6
|
|
7
7
|
def create(params, callback)
|
8
8
|
manager_action callback do
|
9
|
-
resourceables
|
9
|
+
resourceables = params[:resourceables]
|
10
|
+
except_action_methods = params[:except_action_methods] || []
|
10
11
|
|
11
12
|
resource_remover.remove_nonexistent_resources(resourceables)
|
12
13
|
|
13
14
|
resourceables.collect do |resourceable|
|
14
15
|
resource = resource_creator.create(resourceable)
|
15
|
-
action_params = action_params(resource, resourceable)
|
16
|
+
action_params = action_params(resource, resourceable, except_action_methods)
|
16
17
|
|
17
18
|
action_remover.remove_nonexistent_actions(action_params)
|
18
19
|
action_creator.create_many(action_params)
|
@@ -40,8 +41,9 @@ module Arpa
|
|
40
41
|
@action_creator ||= Arpa::Services::Actions::Create::ActionCreator.new
|
41
42
|
end
|
42
43
|
|
43
|
-
def action_params(resource, resourceable)
|
44
|
-
|
44
|
+
def action_params(resource, resourceable, except_action_methods)
|
45
|
+
actions_names = resourceable.action_methods.select{ |action| !except_action_methods.include?(action) }
|
46
|
+
{ resource: resource, actions_names: actions_names }
|
45
47
|
end
|
46
48
|
|
47
49
|
end
|
data/lib/arpa/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe Arpa::Services::Resources::ResourceManagerCreator, type: :service, fast
|
|
8
8
|
let(:action_creator) { double }
|
9
9
|
let(:element) { double }
|
10
10
|
let(:resourceables) { [resourceable_001, resourceable_002] }
|
11
|
-
let(:params) { {resourceables: resourceables} }
|
11
|
+
let(:params) { {resourceables: resourceables, except_action_methods: ['some_method']} }
|
12
12
|
let(:success_proc) { ->(r) {} }
|
13
13
|
let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
|
14
14
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arpa
|
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
|
- Rachid Calazans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|