arpa 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +17 -0
- data/.ruby-version +1 -1
- data/.travis.yml +5 -0
- data/CHANGELOG.md +4 -0
- data/README.md +4 -4
- data/Rakefile +1 -2
- data/arpa.gemspec +17 -18
- data/lib/arpa.rb +65 -67
- data/lib/arpa/additions/resource.rb +0 -2
- data/lib/arpa/data_mappers/action_mapper.rb +1 -2
- data/lib/arpa/data_mappers/base.rb +15 -16
- data/lib/arpa/data_mappers/profile_mapper.rb +3 -4
- data/lib/arpa/data_mappers/resource_mapper.rb +1 -1
- data/lib/arpa/data_mappers/role_mapper.rb +2 -2
- data/lib/arpa/entities/action.rb +0 -2
- data/lib/arpa/entities/profile.rb +2 -3
- data/lib/arpa/entities/resource.rb +4 -6
- data/lib/arpa/entities/role.rb +2 -3
- data/lib/arpa/exceptions/record_invalid.rb +0 -1
- data/lib/arpa/repositories/actions/creator.rb +0 -1
- data/lib/arpa/repositories/actions/finder.rb +5 -6
- data/lib/arpa/repositories/actions/remover.rb +0 -1
- data/lib/arpa/repositories/actions/repository_action.rb +1 -2
- data/lib/arpa/repositories/base.rb +0 -2
- data/lib/arpa/repositories/profiles/creator.rb +0 -1
- data/lib/arpa/repositories/profiles/finder.rb +2 -3
- data/lib/arpa/repositories/profiles/remover.rb +0 -1
- data/lib/arpa/repositories/profiles/repository_profile.rb +1 -2
- data/lib/arpa/repositories/profiles/updater.rb +0 -1
- data/lib/arpa/repositories/registrator.rb +5 -10
- data/lib/arpa/repositories/resources/creator.rb +0 -1
- data/lib/arpa/repositories/resources/finder.rb +0 -1
- data/lib/arpa/repositories/resources/remover.rb +0 -1
- data/lib/arpa/repositories/resources/repository_resource.rb +1 -2
- data/lib/arpa/repositories/roles/creator.rb +0 -1
- data/lib/arpa/repositories/roles/finder.rb +0 -1
- data/lib/arpa/repositories/roles/remover.rb +0 -1
- data/lib/arpa/repositories/roles/repository_role.rb +1 -2
- data/lib/arpa/repositories/roles/updater.rb +0 -1
- data/lib/arpa/services/actions/create/action_creator.rb +1 -3
- data/lib/arpa/services/actions/remove/action_remover.rb +0 -2
- data/lib/arpa/services/base.rb +6 -10
- data/lib/arpa/services/profiles/create/profile_creator.rb +0 -2
- data/lib/arpa/services/profiles/profile_manager_creator.rb +0 -1
- data/lib/arpa/services/profiles/profile_manager_remover.rb +0 -1
- data/lib/arpa/services/profiles/profile_manager_updater.rb +0 -1
- data/lib/arpa/services/profiles/remove/profile_remover.rb +0 -2
- data/lib/arpa/services/profiles/update/profile_updater.rb +0 -2
- data/lib/arpa/services/resources/create/resource_creator.rb +0 -2
- data/lib/arpa/services/resources/remove/resource_remover.rb +1 -4
- data/lib/arpa/services/resources/resource_manager_creator.rb +1 -2
- data/lib/arpa/services/roles/create/role_creator.rb +0 -3
- data/lib/arpa/services/roles/remove/role_remover.rb +0 -2
- data/lib/arpa/services/roles/role_manager_creator.rb +0 -2
- data/lib/arpa/services/roles/role_manager_remover.rb +0 -1
- data/lib/arpa/services/roles/role_manager_updater.rb +0 -1
- data/lib/arpa/services/roles/update/role_updater.rb +0 -2
- data/lib/arpa/services/verifier.rb +0 -1
- data/lib/arpa/validators/action_validator.rb +0 -1
- data/lib/arpa/validators/profile_validator.rb +0 -1
- data/lib/arpa/validators/resource_validator.rb +0 -1
- data/lib/arpa/validators/role_validator.rb +0 -2
- data/lib/arpa/version.rb +1 -1
- data/lib/generators/arpa/controllers_generator.rb +21 -22
- data/lib/generators/arpa/install_generator.rb +5 -6
- data/lib/generators/arpa/templates/controllers/profiles_controller.rb +31 -37
- data/lib/generators/arpa/templates/controllers/resources_controller.rb +20 -11
- data/lib/generators/arpa/templates/controllers/roles_controller.rb +31 -37
- data/lib/generators/arpa/templates/migration.rb +1 -1
- data/spec/factories/repository_actions.rb +4 -5
- data/spec/factories/repository_profiles.rb +4 -5
- data/spec/factories/repository_resources.rb +1 -3
- data/spec/factories/repository_roles.rb +2 -3
- data/spec/factories/repository_test.rb +1 -1
- data/spec/lib/arpa/additions/resource_spec.rb +8 -6
- data/spec/lib/arpa/data_mappers/action_mapper_spec.rb +1 -3
- data/spec/lib/arpa/data_mappers/base_spec.rb +0 -2
- data/spec/lib/arpa/data_mappers/profile_mapper_spec.rb +1 -3
- data/spec/lib/arpa/data_mappers/resource_mapper_spec.rb +1 -3
- data/spec/lib/arpa/data_mappers/role_mapper_spec.rb +1 -3
- data/spec/lib/arpa/entities/action_spec.rb +3 -6
- data/spec/lib/arpa/entities/profile_spec.rb +1 -7
- data/spec/lib/arpa/entities/resource_spec.rb +1 -9
- data/spec/lib/arpa/entities/role_spec.rb +1 -7
- data/spec/lib/arpa/repositories/actions/finder_spec.rb +1 -8
- data/spec/lib/arpa/repositories/base_spec.rb +1 -9
- data/spec/lib/arpa/repositories/profiles/finder_spec.rb +0 -6
- data/spec/lib/arpa/repositories/profiles/remover_spec.rb +0 -4
- data/spec/lib/arpa/repositories/resources/finder_spec.rb +0 -8
- data/spec/lib/arpa/repositories/resources/remover_spec.rb +0 -4
- data/spec/lib/arpa/repositories/roles/finder_spec.rb +0 -4
- data/spec/lib/arpa/repositories/roles/remover_spec.rb +0 -4
- data/spec/lib/arpa/requests/profiles/create_request_spec.rb +10 -12
- data/spec/lib/arpa/requests/profiles/remove_request_spec.rb +4 -9
- data/spec/lib/arpa/requests/resources/create_request_spec.rb +18 -21
- data/spec/lib/arpa/requests/roles/create_request_spec.rb +7 -9
- data/spec/lib/arpa/requests/roles/remove_request_spec.rb +3 -6
- data/spec/lib/arpa/requests/roles/update_request_spec.rb +7 -9
- data/spec/lib/arpa/services/actions/create/action_creator_spec.rb +5 -14
- data/spec/lib/arpa/services/actions/remove/action_remover_spec.rb +3 -6
- data/spec/lib/arpa/services/base_spec.rb +8 -15
- data/spec/lib/arpa/services/profiles/create/profile_creator_spec.rb +0 -7
- data/spec/lib/arpa/services/profiles/profile_manager_creator_spec.rb +2 -4
- data/spec/lib/arpa/services/profiles/profile_manager_remover_spec.rb +3 -6
- data/spec/lib/arpa/services/profiles/profile_manager_updater_spec.rb +2 -4
- data/spec/lib/arpa/services/profiles/remove/profile_remover_spec.rb +0 -5
- data/spec/lib/arpa/services/profiles/update/profile_updater_spec.rb +0 -7
- data/spec/lib/arpa/services/resources/create/resource_creator_spec.rb +1 -7
- data/spec/lib/arpa/services/resources/remove/resource_remover_spec.rb +2 -6
- data/spec/lib/arpa/services/resources/resource_manager_creator_spec.rb +5 -7
- data/spec/lib/arpa/services/roles/create/role_creator_spec.rb +0 -7
- data/spec/lib/arpa/services/roles/remove/role_remover_spec.rb +1 -8
- data/spec/lib/arpa/services/roles/role_manager_creator_spec.rb +2 -4
- data/spec/lib/arpa/services/roles/role_manager_remover_spec.rb +2 -4
- data/spec/lib/arpa/services/roles/role_manager_updater_spec.rb +2 -4
- data/spec/lib/arpa/services/roles/update/role_updater_spec.rb +0 -7
- data/spec/lib/arpa/services/verifier_spec.rb +3 -6
- data/spec/lib/arpa/validators/action_validator_spec.rb +0 -1
- data/spec/lib/arpa/validators/profile_validator_spec.rb +1 -2
- data/spec/lib/arpa/validators/resource_validator_spec.rb +0 -1
- data/spec/lib/arpa/validators/role_validator_spec.rb +1 -2
- data/spec/spec_helper.rb +4 -6
- data/spec/support/schema.rb +9 -10
- metadata +40 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b13fa52d645e48d52cc049a8b079b382a526adc17b9596f6971f1254dffcd9af
|
4
|
+
data.tar.gz: a4e4ed7a9cb0b52a1ef553e1f68b52b54ab66f819a1620a1b4bf31eb496d3b35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e87587cfc95adfd2b33a55216102253161cefd0a0f59d7ae252767c26c81d84c6f879ab63acb249842bfbfedfbfcaf03f168bb4f53144f20932f3a5b5e42207
|
7
|
+
data.tar.gz: 119d297e6ed1bb7aa6ff3f78f8d5a1916df0e63041f58cc6224ab9fd3c23b6ba62f12122760b116e879c7274e47a38cf7a8fa0089ad7e762d0c2afc995aa4ff7
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
ExtraDetails: false
|
5
|
+
TargetRubyVersion: 2.5
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 120
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
ExcludedMethods: ['describe', 'context', 'define']
|
12
|
+
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/FrozenStringLiteralComment:
|
17
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.5.1
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#Arpa
|
1
|
+
# Arpa
|
2
2
|
|
3
3
|
Arpa is an authorization library for Ruby or Ruby on Rails which restricts the accesses in controller and actions. Arpa will help you to customize all permissions you need dynamically.
|
4
4
|
|
@@ -35,13 +35,13 @@ If you want a different Model to associate with Arpa::Profile you can pass some
|
|
35
35
|
|
36
36
|
$ rails generate arpa:install [ASSOCIATE_TABLE] [ASSOCIATE_PRIMARY_KEY]
|
37
37
|
|
38
|
-
####Eg. 1:
|
38
|
+
#### Eg. 1:
|
39
39
|
|
40
40
|
$ rails generate arpa:install admins
|
41
41
|
|
42
42
|
That command will create the association with **admins** table with **admin_id** as foreign key.
|
43
43
|
|
44
|
-
####Eg. 2:
|
44
|
+
#### Eg. 2:
|
45
45
|
|
46
46
|
$ rails generate arpa:install admins admin_custom_id
|
47
47
|
|
@@ -152,7 +152,7 @@ Arpa will use on **description** method from Arpa::Entities::Action a specific L
|
|
152
152
|
|
153
153
|
You should create a locale file to print correctly the descriptions of the actions.
|
154
154
|
|
155
|
-
####Eg.:
|
155
|
+
#### Eg.:
|
156
156
|
|
157
157
|
```ruby
|
158
158
|
en:
|
data/Rakefile
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
data/arpa.gemspec
CHANGED
@@ -1,32 +1,31 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'arpa/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'arpa'
|
8
7
|
spec.version = Arpa::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.summary =
|
11
|
-
spec.email = [
|
12
|
-
spec.license =
|
13
|
-
spec.homepage =
|
14
|
-
spec.description =
|
8
|
+
spec.authors = ['Rachid Calazans']
|
9
|
+
spec.summary = 'Authorization Gem for Ruby and Ruby on Rails projects'
|
10
|
+
spec.email = ['rachidcalazans@gmail.com']
|
11
|
+
spec.license = 'MIT'
|
12
|
+
spec.homepage = 'https://github.com/rachidcalazans/arpa'
|
13
|
+
spec.description = 'Authorization Gem for Ruby and Ruby on Rails projects'
|
15
14
|
|
16
15
|
spec.files = `git ls-files -z`.split("\x0")
|
17
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
20
19
|
|
21
|
-
spec.add_development_dependency 'bundler'
|
22
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.3', '>= 3.3.0'
|
24
|
-
spec.add_development_dependency 'factory_girl'
|
25
|
-
spec.add_development_dependency 'sqlite3', '~> 1.3', '>= 1.3.3'
|
20
|
+
spec.add_development_dependency 'bundler'
|
26
21
|
spec.add_development_dependency 'database_cleaner'
|
22
|
+
spec.add_development_dependency 'factory_bot'
|
27
23
|
spec.add_development_dependency 'pry'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'rubocop'
|
27
|
+
spec.add_development_dependency 'sqlite3'
|
28
28
|
|
29
|
-
spec.add_dependency 'activerecord'
|
30
|
-
spec.add_dependency 'railties'
|
31
|
-
|
29
|
+
spec.add_dependency 'activerecord'
|
30
|
+
spec.add_dependency 'railties'
|
32
31
|
end
|
data/lib/arpa.rb
CHANGED
@@ -1,90 +1,88 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'arpa/version'
|
2
|
+
require 'rails/railtie'
|
3
3
|
|
4
4
|
# Additions
|
5
|
-
require
|
5
|
+
require 'arpa/additions/resource'
|
6
6
|
|
7
7
|
# Exceptions
|
8
|
-
require
|
8
|
+
require 'arpa/exceptions/record_invalid'
|
9
9
|
|
10
10
|
# Entities
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
11
|
+
require 'arpa/entities/resource'
|
12
|
+
require 'arpa/entities/action'
|
13
|
+
require 'arpa/entities/role'
|
14
|
+
require 'arpa/entities/profile'
|
15
15
|
|
16
16
|
# Mappers
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
17
|
+
require 'arpa/data_mappers/base'
|
18
|
+
require 'arpa/data_mappers/resource_mapper'
|
19
|
+
require 'arpa/data_mappers/action_mapper'
|
20
|
+
require 'arpa/data_mappers/role_mapper'
|
21
|
+
require 'arpa/data_mappers/profile_mapper'
|
22
22
|
|
23
23
|
# Validators
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
24
|
+
require 'arpa/validators/resource_validator'
|
25
|
+
require 'arpa/validators/action_validator'
|
26
|
+
require 'arpa/validators/role_validator'
|
27
|
+
require 'arpa/validators/profile_validator'
|
28
28
|
|
29
29
|
# Repositories
|
30
|
-
require
|
31
|
-
require
|
32
|
-
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
|
38
|
-
require
|
39
|
-
require
|
40
|
-
require
|
41
|
-
require
|
42
|
-
|
43
|
-
require
|
44
|
-
require
|
45
|
-
require
|
46
|
-
require
|
47
|
-
require
|
48
|
-
|
49
|
-
require
|
50
|
-
require
|
51
|
-
require
|
52
|
-
require
|
53
|
-
require
|
30
|
+
require 'arpa/repositories/base'
|
31
|
+
require 'arpa/repositories/registrator'
|
32
|
+
|
33
|
+
require 'arpa/repositories/resources/repository_resource'
|
34
|
+
require 'arpa/repositories/resources/finder'
|
35
|
+
require 'arpa/repositories/resources/remover'
|
36
|
+
require 'arpa/repositories/resources/creator'
|
37
|
+
|
38
|
+
require 'arpa/repositories/actions/repository_action'
|
39
|
+
require 'arpa/repositories/actions/finder'
|
40
|
+
require 'arpa/repositories/actions/remover'
|
41
|
+
require 'arpa/repositories/actions/creator'
|
42
|
+
|
43
|
+
require 'arpa/repositories/roles/repository_role'
|
44
|
+
require 'arpa/repositories/roles/finder'
|
45
|
+
require 'arpa/repositories/roles/creator'
|
46
|
+
require 'arpa/repositories/roles/updater'
|
47
|
+
require 'arpa/repositories/roles/remover'
|
48
|
+
|
49
|
+
require 'arpa/repositories/profiles/repository_profile'
|
50
|
+
require 'arpa/repositories/profiles/finder'
|
51
|
+
require 'arpa/repositories/profiles/creator'
|
52
|
+
require 'arpa/repositories/profiles/updater'
|
53
|
+
require 'arpa/repositories/profiles/remover'
|
54
54
|
|
55
55
|
# Services
|
56
|
-
require
|
57
|
-
require
|
58
|
-
|
59
|
-
require
|
60
|
-
require
|
61
|
-
|
62
|
-
require
|
63
|
-
require
|
64
|
-
require
|
65
|
-
|
66
|
-
require
|
67
|
-
require
|
68
|
-
require
|
69
|
-
require
|
70
|
-
require
|
71
|
-
require
|
72
|
-
|
73
|
-
require
|
74
|
-
require
|
75
|
-
require
|
76
|
-
require
|
77
|
-
require
|
78
|
-
require
|
56
|
+
require 'arpa/services/base'
|
57
|
+
require 'arpa/services/verifier'
|
58
|
+
|
59
|
+
require 'arpa/services/actions/create/action_creator'
|
60
|
+
require 'arpa/services/actions/remove/action_remover'
|
61
|
+
|
62
|
+
require 'arpa/services/resources/create/resource_creator'
|
63
|
+
require 'arpa/services/resources/remove/resource_remover'
|
64
|
+
require 'arpa/services/resources/resource_manager_creator'
|
65
|
+
|
66
|
+
require 'arpa/services/roles/role_manager_creator'
|
67
|
+
require 'arpa/services/roles/role_manager_updater'
|
68
|
+
require 'arpa/services/roles/role_manager_remover'
|
69
|
+
require 'arpa/services/roles/create/role_creator'
|
70
|
+
require 'arpa/services/roles/update/role_updater'
|
71
|
+
require 'arpa/services/roles/remove/role_remover'
|
72
|
+
|
73
|
+
require 'arpa/services/profiles/profile_manager_creator'
|
74
|
+
require 'arpa/services/profiles/profile_manager_updater'
|
75
|
+
require 'arpa/services/profiles/profile_manager_remover'
|
76
|
+
require 'arpa/services/profiles/create/profile_creator'
|
77
|
+
require 'arpa/services/profiles/update/profile_updater'
|
78
|
+
require 'arpa/services/profiles/remove/profile_remover'
|
79
79
|
|
80
80
|
module Arpa
|
81
|
-
|
82
81
|
class Railtie < ::Rails::Railtie
|
83
|
-
initializer
|
82
|
+
initializer 'arpa.configure_view_controller' do |_app|
|
84
83
|
ActiveSupport.on_load :action_controller do
|
85
84
|
include Arpa::Additions::Resource
|
86
85
|
end
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
90
88
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Arpa
|
2
2
|
module Additions
|
3
3
|
module Resource
|
4
|
-
|
5
4
|
def self.included(base)
|
6
5
|
base.helper_method :has_access?
|
7
6
|
end
|
@@ -24,7 +23,6 @@ module Arpa
|
|
24
23
|
log.warn("The ApplicationController must has a attribute or method 'current_user'") unless verified_current_user
|
25
24
|
false
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -5,9 +5,8 @@ module Arpa
|
|
5
5
|
repository_class 'Arpa::Repositories::Actions::RepositoryAction'
|
6
6
|
|
7
7
|
attrs_to_entity :id, :resource_id, :name, :created_at, :updated_at,
|
8
|
-
|
8
|
+
resource: { mapper: 'Arpa::DataMappers::ResourceMapper' }
|
9
9
|
attrs_to_record :id, :resource_id, :name, :created_at, :updated_at
|
10
|
-
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -3,14 +3,14 @@ module Arpa
|
|
3
3
|
class Base
|
4
4
|
include Singleton
|
5
5
|
|
6
|
-
def map_to_record(entity, options={})
|
6
|
+
def map_to_record(entity, options = {})
|
7
7
|
options[:map_association_to] ||= :map_to_record
|
8
8
|
attrs_to_record = self.class._attrs_to_record
|
9
9
|
attributes = attributes_from(entity, attrs_to_record, options)
|
10
10
|
self.class._repository_class.new(attributes)
|
11
11
|
end
|
12
12
|
|
13
|
-
def map_to_entity(record, options={})
|
13
|
+
def map_to_entity(record, options = {})
|
14
14
|
options[:map_association_to] ||= :map_to_entity
|
15
15
|
attrs_to_entity = self.class._attrs_to_entity
|
16
16
|
attributes = attributes_from(record, attrs_to_entity, options)
|
@@ -19,37 +19,37 @@ module Arpa
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def attributes_from(object, attrs_to_map, options={})
|
22
|
+
def attributes_from(object, attrs_to_map, options = {})
|
23
23
|
options[:map_association_to] = options.fetch(:map_association_to, :map_to_entity)
|
24
24
|
options[:map_association] = options.fetch(:map_association, true)
|
25
25
|
|
26
26
|
attrs_to_map ||= self.class._attributes_to_map
|
27
27
|
|
28
28
|
begin
|
29
|
-
|
30
|
-
rescue => e
|
29
|
+
build_hash_attributes(attrs_to_map, object, options)
|
30
|
+
rescue StandardError => e
|
31
31
|
raise StandardError, "#{self.class} -> #{e.message}"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def build_hash_attributes(attributes_to_map, object, options)
|
36
|
-
builder_attribute = build_hash_attribute.curry.(object, options)
|
36
|
+
builder_attribute = build_hash_attribute.curry.call(object, options)
|
37
37
|
|
38
|
-
attributes_to_map.collect
|
39
|
-
builder_attribute.(attr_key)
|
40
|
-
|
38
|
+
attributes_to_map.collect do |attr_key|
|
39
|
+
builder_attribute.call(attr_key)
|
40
|
+
end.reduce({}, :merge)
|
41
41
|
end
|
42
42
|
|
43
43
|
def build_hash_attribute
|
44
|
-
|
45
|
-
if attr_key.
|
44
|
+
lambda { |object, options, attr_key|
|
45
|
+
if attr_key.is_a?(Hash)
|
46
46
|
key = attr_key.keys.first
|
47
47
|
value = association_value(object, attr_key, options)
|
48
48
|
else
|
49
49
|
key = attr_key
|
50
|
-
value = object.send(attr_key)
|
50
|
+
value = object.send(attr_key) if object.respond_to?(attr_key)
|
51
51
|
end
|
52
|
-
{:"#{key}" => value}
|
52
|
+
{ :"#{key}" => value }
|
53
53
|
}
|
54
54
|
end
|
55
55
|
|
@@ -63,10 +63,10 @@ module Arpa
|
|
63
63
|
|
64
64
|
if object_value.try(:size)
|
65
65
|
object_value.collect do |obj|
|
66
|
-
mapper.send(options[:map_association_to], obj,
|
66
|
+
mapper.send(options[:map_association_to], obj, map_association: false)
|
67
67
|
end
|
68
68
|
else
|
69
|
-
mapper.send(options[:map_association_to], object_value,
|
69
|
+
mapper.send(options[:map_association_to], object_value, map_association: false)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -111,7 +111,6 @@ module Arpa
|
|
111
111
|
def self._attrs_to_entity
|
112
112
|
@attrs_to_entity
|
113
113
|
end
|
114
|
-
|
115
114
|
end
|
116
115
|
end
|
117
116
|
end
|
@@ -5,12 +5,11 @@ module Arpa
|
|
5
5
|
repository_class 'Arpa::Repositories::Profiles::RepositoryProfile'
|
6
6
|
|
7
7
|
attrs_to_entity :id, :name, :description, :role_ids, :entity_id, :entity_class,
|
8
|
-
|
9
|
-
|
8
|
+
:created_at, :updated_at, :removed,
|
9
|
+
roles: { mapper: 'Arpa::DataMappers::RoleMapper' }
|
10
10
|
|
11
11
|
attrs_to_record :id, :name, :description, :role_ids, :entity_id, :entity_class,
|
12
|
-
|
13
|
-
|
12
|
+
:created_at, :updated_at, :removed
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
@@ -5,8 +5,8 @@ module Arpa
|
|
5
5
|
repository_class 'Arpa::Repositories::Roles::RepositoryRole'
|
6
6
|
|
7
7
|
attrs_to_entity :id, :name, :description, :action_ids, :removed, :created_at, :updated_at,
|
8
|
-
|
9
|
-
|
8
|
+
{ actions: { mapper: 'Arpa::DataMappers::ActionMapper' } },
|
9
|
+
profiles: { mapper: 'Arpa::DataMappers::ProfileMapper' }
|
10
10
|
|
11
11
|
attrs_to_record :id, :name, :description, :action_ids, :removed, :created_at, :updated_at
|
12
12
|
end
|
data/lib/arpa/entities/action.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Arpa
|
2
2
|
module Entities
|
3
3
|
class Action
|
4
|
-
|
5
4
|
attr_reader :id, :resource_id, :resource, :name, :created_at, :updated_at
|
6
5
|
|
7
6
|
def initialize(attrs = {})
|
@@ -23,7 +22,6 @@ module Arpa
|
|
23
22
|
def description
|
24
23
|
I18n.t(name.to_sym, scope: "entities.resources.#{resource_name}.actions.description")
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|