the_role 2.5.2 → 2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/admin/roles_controller.rb +1 -1
- data/app/models/concerns/role.rb +15 -3
- data/config/locales/en.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/lib/the_role/version.rb +1 -1
- data/spec/dummy_app/Gemfile +8 -4
- 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: 2c29fc0d973ff434fce0aa391383b08339ca3892
|
4
|
+
data.tar.gz: df6130fb9708c35a2a918c043cecb3e6cf2cbc48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db22cab2f348f17cc28282f308d45a5371228ea8a0c38b45b7035d9806344a37b06a4825a908fdd3cd6d8d01eba4e60e7170302a8605877e137c4789e55fc304
|
7
|
+
data.tar.gz: 6bc9f19977d48ee6a0fa59a42fa2dc0f3dacd9116fbb3cc46580934602e7e570572c5e342be89588b76eac1e21447e5f9533d024ca8ff25bfae0e1956cd574d7
|
data/README.md
CHANGED
@@ -56,7 +56,7 @@ class Admin::RolesController < ApplicationController
|
|
56
56
|
protected
|
57
57
|
|
58
58
|
def role_params
|
59
|
-
params.require(:role).permit(:name, :title, :description, :the_role)
|
59
|
+
params.require(:role).permit(:name, :title, :description, :the_role, :based_on_role)
|
60
60
|
end
|
61
61
|
|
62
62
|
def role_find
|
data/app/models/concerns/role.rb
CHANGED
@@ -16,17 +16,29 @@ module TheRole
|
|
16
16
|
end
|
17
17
|
|
18
18
|
included do
|
19
|
+
attr_accessor :based_on_role
|
20
|
+
|
19
21
|
has_many :users, dependent: TheRole.config.destroy_strategy
|
20
22
|
validates :name, presence: true, uniqueness: true
|
21
23
|
validates :title, presence: true, uniqueness: true
|
22
24
|
validates :description, presence: true
|
23
25
|
|
26
|
+
private
|
27
|
+
|
24
28
|
before_save do
|
25
29
|
self.name = name.to_slug_param(sep: '_')
|
26
30
|
|
27
|
-
rules_set
|
28
|
-
self.the_role = {}.to_json
|
29
|
-
self.the_role = rules_set.to_json if rules_set.is_a?(Hash)
|
31
|
+
rules_set = self.the_role
|
32
|
+
self.the_role = {}.to_json if rules_set.blank?
|
33
|
+
self.the_role = rules_set.to_json if rules_set.is_a?(Hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
after_create do
|
37
|
+
unless based_on_role.blank?
|
38
|
+
if base_role = self.class.where(id: based_on_role).first
|
39
|
+
update_role base_role.to_hash
|
40
|
+
end
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
32
44
|
|
data/config/locales/en.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/lib/the_role/version.rb
CHANGED
data/spec/dummy_app/Gemfile
CHANGED
@@ -18,17 +18,21 @@ gem 'uglifier'
|
|
18
18
|
gem 'jquery-rails'
|
19
19
|
gem 'jbuilder', '~> 1.0.1'
|
20
20
|
|
21
|
-
gem 'the_string_to_slug',
|
22
|
-
path: "../../../the_string_to_slug"
|
21
|
+
# gem 'the_string_to_slug', path: "../../../the_string_to_slug"
|
23
22
|
|
24
23
|
gem 'the_role',
|
25
|
-
#
|
26
|
-
|
24
|
+
# path: '../../'
|
25
|
+
"~> 2.5.3"
|
27
26
|
|
28
27
|
gem 'the_role_bootstrap3_ui',
|
28
|
+
# path: "path: '../../../../../the_role_bootstrap3_ui"
|
29
29
|
github: 'the-teacher/the_role_bootstrap3_ui',
|
30
30
|
branch: 'master'
|
31
31
|
|
32
|
+
group :development do
|
33
|
+
gem 'pry-rails'
|
34
|
+
end
|
35
|
+
|
32
36
|
group :test do
|
33
37
|
gem 'factory_girl_rails', '~> 4.0'
|
34
38
|
gem 'database_cleaner', git: 'https://github.com/bmabey/database_cleaner.git', tag: 'v1.0.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya N. Zykin [the-teacher]
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: the_string_to_slug
|