arpa 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +17 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +4 -0
  6. data/README.md +4 -4
  7. data/Rakefile +1 -2
  8. data/arpa.gemspec +17 -18
  9. data/lib/arpa.rb +65 -67
  10. data/lib/arpa/additions/resource.rb +0 -2
  11. data/lib/arpa/data_mappers/action_mapper.rb +1 -2
  12. data/lib/arpa/data_mappers/base.rb +15 -16
  13. data/lib/arpa/data_mappers/profile_mapper.rb +3 -4
  14. data/lib/arpa/data_mappers/resource_mapper.rb +1 -1
  15. data/lib/arpa/data_mappers/role_mapper.rb +2 -2
  16. data/lib/arpa/entities/action.rb +0 -2
  17. data/lib/arpa/entities/profile.rb +2 -3
  18. data/lib/arpa/entities/resource.rb +4 -6
  19. data/lib/arpa/entities/role.rb +2 -3
  20. data/lib/arpa/exceptions/record_invalid.rb +0 -1
  21. data/lib/arpa/repositories/actions/creator.rb +0 -1
  22. data/lib/arpa/repositories/actions/finder.rb +5 -6
  23. data/lib/arpa/repositories/actions/remover.rb +0 -1
  24. data/lib/arpa/repositories/actions/repository_action.rb +1 -2
  25. data/lib/arpa/repositories/base.rb +0 -2
  26. data/lib/arpa/repositories/profiles/creator.rb +0 -1
  27. data/lib/arpa/repositories/profiles/finder.rb +2 -3
  28. data/lib/arpa/repositories/profiles/remover.rb +0 -1
  29. data/lib/arpa/repositories/profiles/repository_profile.rb +1 -2
  30. data/lib/arpa/repositories/profiles/updater.rb +0 -1
  31. data/lib/arpa/repositories/registrator.rb +5 -10
  32. data/lib/arpa/repositories/resources/creator.rb +0 -1
  33. data/lib/arpa/repositories/resources/finder.rb +0 -1
  34. data/lib/arpa/repositories/resources/remover.rb +0 -1
  35. data/lib/arpa/repositories/resources/repository_resource.rb +1 -2
  36. data/lib/arpa/repositories/roles/creator.rb +0 -1
  37. data/lib/arpa/repositories/roles/finder.rb +0 -1
  38. data/lib/arpa/repositories/roles/remover.rb +0 -1
  39. data/lib/arpa/repositories/roles/repository_role.rb +1 -2
  40. data/lib/arpa/repositories/roles/updater.rb +0 -1
  41. data/lib/arpa/services/actions/create/action_creator.rb +1 -3
  42. data/lib/arpa/services/actions/remove/action_remover.rb +0 -2
  43. data/lib/arpa/services/base.rb +6 -10
  44. data/lib/arpa/services/profiles/create/profile_creator.rb +0 -2
  45. data/lib/arpa/services/profiles/profile_manager_creator.rb +0 -1
  46. data/lib/arpa/services/profiles/profile_manager_remover.rb +0 -1
  47. data/lib/arpa/services/profiles/profile_manager_updater.rb +0 -1
  48. data/lib/arpa/services/profiles/remove/profile_remover.rb +0 -2
  49. data/lib/arpa/services/profiles/update/profile_updater.rb +0 -2
  50. data/lib/arpa/services/resources/create/resource_creator.rb +0 -2
  51. data/lib/arpa/services/resources/remove/resource_remover.rb +1 -4
  52. data/lib/arpa/services/resources/resource_manager_creator.rb +1 -2
  53. data/lib/arpa/services/roles/create/role_creator.rb +0 -3
  54. data/lib/arpa/services/roles/remove/role_remover.rb +0 -2
  55. data/lib/arpa/services/roles/role_manager_creator.rb +0 -2
  56. data/lib/arpa/services/roles/role_manager_remover.rb +0 -1
  57. data/lib/arpa/services/roles/role_manager_updater.rb +0 -1
  58. data/lib/arpa/services/roles/update/role_updater.rb +0 -2
  59. data/lib/arpa/services/verifier.rb +0 -1
  60. data/lib/arpa/validators/action_validator.rb +0 -1
  61. data/lib/arpa/validators/profile_validator.rb +0 -1
  62. data/lib/arpa/validators/resource_validator.rb +0 -1
  63. data/lib/arpa/validators/role_validator.rb +0 -2
  64. data/lib/arpa/version.rb +1 -1
  65. data/lib/generators/arpa/controllers_generator.rb +21 -22
  66. data/lib/generators/arpa/install_generator.rb +5 -6
  67. data/lib/generators/arpa/templates/controllers/profiles_controller.rb +31 -37
  68. data/lib/generators/arpa/templates/controllers/resources_controller.rb +20 -11
  69. data/lib/generators/arpa/templates/controllers/roles_controller.rb +31 -37
  70. data/lib/generators/arpa/templates/migration.rb +1 -1
  71. data/spec/factories/repository_actions.rb +4 -5
  72. data/spec/factories/repository_profiles.rb +4 -5
  73. data/spec/factories/repository_resources.rb +1 -3
  74. data/spec/factories/repository_roles.rb +2 -3
  75. data/spec/factories/repository_test.rb +1 -1
  76. data/spec/lib/arpa/additions/resource_spec.rb +8 -6
  77. data/spec/lib/arpa/data_mappers/action_mapper_spec.rb +1 -3
  78. data/spec/lib/arpa/data_mappers/base_spec.rb +0 -2
  79. data/spec/lib/arpa/data_mappers/profile_mapper_spec.rb +1 -3
  80. data/spec/lib/arpa/data_mappers/resource_mapper_spec.rb +1 -3
  81. data/spec/lib/arpa/data_mappers/role_mapper_spec.rb +1 -3
  82. data/spec/lib/arpa/entities/action_spec.rb +3 -6
  83. data/spec/lib/arpa/entities/profile_spec.rb +1 -7
  84. data/spec/lib/arpa/entities/resource_spec.rb +1 -9
  85. data/spec/lib/arpa/entities/role_spec.rb +1 -7
  86. data/spec/lib/arpa/repositories/actions/finder_spec.rb +1 -8
  87. data/spec/lib/arpa/repositories/base_spec.rb +1 -9
  88. data/spec/lib/arpa/repositories/profiles/finder_spec.rb +0 -6
  89. data/spec/lib/arpa/repositories/profiles/remover_spec.rb +0 -4
  90. data/spec/lib/arpa/repositories/resources/finder_spec.rb +0 -8
  91. data/spec/lib/arpa/repositories/resources/remover_spec.rb +0 -4
  92. data/spec/lib/arpa/repositories/roles/finder_spec.rb +0 -4
  93. data/spec/lib/arpa/repositories/roles/remover_spec.rb +0 -4
  94. data/spec/lib/arpa/requests/profiles/create_request_spec.rb +10 -12
  95. data/spec/lib/arpa/requests/profiles/remove_request_spec.rb +4 -9
  96. data/spec/lib/arpa/requests/resources/create_request_spec.rb +18 -21
  97. data/spec/lib/arpa/requests/roles/create_request_spec.rb +7 -9
  98. data/spec/lib/arpa/requests/roles/remove_request_spec.rb +3 -6
  99. data/spec/lib/arpa/requests/roles/update_request_spec.rb +7 -9
  100. data/spec/lib/arpa/services/actions/create/action_creator_spec.rb +5 -14
  101. data/spec/lib/arpa/services/actions/remove/action_remover_spec.rb +3 -6
  102. data/spec/lib/arpa/services/base_spec.rb +8 -15
  103. data/spec/lib/arpa/services/profiles/create/profile_creator_spec.rb +0 -7
  104. data/spec/lib/arpa/services/profiles/profile_manager_creator_spec.rb +2 -4
  105. data/spec/lib/arpa/services/profiles/profile_manager_remover_spec.rb +3 -6
  106. data/spec/lib/arpa/services/profiles/profile_manager_updater_spec.rb +2 -4
  107. data/spec/lib/arpa/services/profiles/remove/profile_remover_spec.rb +0 -5
  108. data/spec/lib/arpa/services/profiles/update/profile_updater_spec.rb +0 -7
  109. data/spec/lib/arpa/services/resources/create/resource_creator_spec.rb +1 -7
  110. data/spec/lib/arpa/services/resources/remove/resource_remover_spec.rb +2 -6
  111. data/spec/lib/arpa/services/resources/resource_manager_creator_spec.rb +5 -7
  112. data/spec/lib/arpa/services/roles/create/role_creator_spec.rb +0 -7
  113. data/spec/lib/arpa/services/roles/remove/role_remover_spec.rb +1 -8
  114. data/spec/lib/arpa/services/roles/role_manager_creator_spec.rb +2 -4
  115. data/spec/lib/arpa/services/roles/role_manager_remover_spec.rb +2 -4
  116. data/spec/lib/arpa/services/roles/role_manager_updater_spec.rb +2 -4
  117. data/spec/lib/arpa/services/roles/update/role_updater_spec.rb +0 -7
  118. data/spec/lib/arpa/services/verifier_spec.rb +3 -6
  119. data/spec/lib/arpa/validators/action_validator_spec.rb +0 -1
  120. data/spec/lib/arpa/validators/profile_validator_spec.rb +1 -2
  121. data/spec/lib/arpa/validators/resource_validator_spec.rb +0 -1
  122. data/spec/lib/arpa/validators/role_validator_spec.rb +1 -2
  123. data/spec/spec_helper.rb +4 -6
  124. data/spec/support/schema.rb +9 -10
  125. metadata +40 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e273592f37ad13daf44a6e0c412ec460ce55d7e9
4
- data.tar.gz: eb130f2d9ccb47a7593ffabda100d1751aa479d5
2
+ SHA256:
3
+ metadata.gz: b13fa52d645e48d52cc049a8b079b382a526adc17b9596f6971f1254dffcd9af
4
+ data.tar.gz: a4e4ed7a9cb0b52a1ef553e1f68b52b54ab66f819a1620a1b4bf31eb496d3b35
5
5
  SHA512:
6
- metadata.gz: ebfe4e7018c0f15bce6d177f36e9286c996fde7e5895bd5814d1cb28709fe6e79d98a786b567bb7af13a6e110e3c03681d70da4c1a7f0d4dda52221bbeb43a89
7
- data.tar.gz: c3091d712f1b4fc02c87b81770be3f5253e79d3bed28dd14059c69876bf835c06ebb5e2a5bb628b87d6dfb6bc6b555264c517ad6b10bd7099b15e78c69484ee5
6
+ metadata.gz: 5e87587cfc95adfd2b33a55216102253161cefd0a0f59d7ae252767c26c81d84c6f879ab63acb249842bfbfedfbfcaf03f168bb4f53144f20932f3a5b5e42207
7
+ data.tar.gz: 119d297e6ed1bb7aa6ff3f78f8d5a1916df0e63041f58cc6224ab9fd3c23b6ba62f12122760b116e879c7274e47a38cf7a8fa0089ad7e762d0c2afc995aa4ff7
@@ -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
@@ -1 +1 @@
1
- ruby-2.2.0
1
+ ruby-2.5.1
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - 2.4.2
5
+ script: bundle exec rspec spec
@@ -1,3 +1,7 @@
1
+ ### 0.3.0
2
+ * changes
3
+ * Update project to use rails 5.2
4
+
1
5
  ### 0.2.0
2
6
 
3
7
  * additions
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 "bundler/gem_tasks"
2
-
1
+ require 'bundler/gem_tasks'
@@ -1,32 +1,31 @@
1
- # coding: utf-8
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 = "arpa"
6
+ spec.name = 'arpa'
8
7
  spec.version = Arpa::VERSION
9
- spec.authors = ["Rachid Calazans"]
10
- spec.summary = "Authorization Gem for Ruby and Ruby on Rails projects"
11
- spec.email = ["rachidcalazans@gmail.com"]
12
- spec.license = "MIT"
13
- spec.homepage = "https://github.com/rachidcalazans/arpa"
14
- spec.description = "Authorization Gem for Ruby and Ruby on Rails projects"
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 = ["lib"]
18
+ spec.require_paths = ['lib']
20
19
 
21
- spec.add_development_dependency 'bundler', '~> 1.7'
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', '>= 4.2.0'
30
- spec.add_dependency 'railties', '>= 4.2.0'
31
-
29
+ spec.add_dependency 'activerecord'
30
+ spec.add_dependency 'railties'
32
31
  end
@@ -1,90 +1,88 @@
1
- require "arpa/version"
2
- require "rails/railtie"
1
+ require 'arpa/version'
2
+ require 'rails/railtie'
3
3
 
4
4
  # Additions
5
- require "arpa/additions/resource"
5
+ require 'arpa/additions/resource'
6
6
 
7
7
  # Exceptions
8
- require "arpa/exceptions/record_invalid"
8
+ require 'arpa/exceptions/record_invalid'
9
9
 
10
10
  # Entities
11
- require "arpa/entities/resource"
12
- require "arpa/entities/action"
13
- require "arpa/entities/role"
14
- require "arpa/entities/profile"
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 "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"
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 "arpa/validators/resource_validator"
25
- require "arpa/validators/action_validator"
26
- require "arpa/validators/role_validator"
27
- require "arpa/validators/profile_validator"
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 "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"
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 "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"
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 "arpa.configure_view_controller" do |app|
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
- resource: {mapper: 'Arpa::DataMappers::ResourceMapper'}
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
- build_hash_attributes(attrs_to_map, object, options)
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 { |attr_key|
39
- builder_attribute.(attr_key)
40
- }.reduce({}, :merge)
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
- -> (object, options, attr_key) {
45
- if attr_key.kind_of?(Hash)
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, {map_association: false})
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, {map_association: false})
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
- :created_at, :updated_at, :removed,
9
- roles: {mapper: 'Arpa::DataMappers::RoleMapper'}
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
- :created_at, :updated_at, :removed
13
-
12
+ :created_at, :updated_at, :removed
14
13
  end
15
14
  end
16
15
  end
@@ -5,7 +5,7 @@ module Arpa
5
5
  repository_class 'Arpa::Repositories::Resources::RepositoryResource'
6
6
 
7
7
  attributes_to_map :id, :name, :full_name,
8
- actions: {mapper: 'Arpa::DataMappers::ActionMapper'}
8
+ actions: { mapper: 'Arpa::DataMappers::ActionMapper' }
9
9
  end
10
10
  end
11
11
  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
- {actions: {mapper: 'Arpa::DataMappers::ActionMapper'} },
9
- {profiles: {mapper: 'Arpa::DataMappers::ProfileMapper'}}
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
@@ -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