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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12b0ae2b2e4a5afcc9026717b0c81155f02fa4d7
4
- data.tar.gz: 7867224f80ba6715d9d3a562e77ea04f642a592f
3
+ metadata.gz: 2c29fc0d973ff434fce0aa391383b08339ca3892
4
+ data.tar.gz: df6130fb9708c35a2a918c043cecb3e6cf2cbc48
5
5
  SHA512:
6
- metadata.gz: e768d539904516605ab9be3e3de04debe263116639edf2891eef306ced2db0c16008d3a7f9cfe3cc73f3ec054ca62d60deda76703e821c99d083d20ee7ee8681
7
- data.tar.gz: d343d3fc7478400b0903eb278b0db31ce0653a27bf69ef478d9bd91486fafa06843bf9c57b01bd55c0903ff9ae07aa1ef4239534953396fa72c482ac5ffc1d4d
6
+ metadata.gz: db22cab2f348f17cc28282f308d45a5371228ea8a0c38b45b7035d9806344a37b06a4825a908fdd3cd6d8d01eba4e60e7170302a8605877e137c4789e55fc304
7
+ data.tar.gz: 6bc9f19977d48ee6a0fa59a42fa2dc0f3dacd9116fbb3cc46580934602e7e570572c5e342be89588b76eac1e21447e5f9533d024ca8ff25bfae0e1956cd574d7
data/README.md CHANGED
@@ -44,7 +44,7 @@ puts following yields into your layout:
44
44
  ### Rails 4 version
45
45
 
46
46
  ```
47
- gem 'the_role', '~> 2.4'
47
+ gem 'the_role', '~> 2.5.2'
48
48
 
49
49
  gem 'the_role_bootstrap3_ui'
50
50
  ```
@@ -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
@@ -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 = self.the_role
28
- self.the_role = {}.to_json if rules_set.blank? # blank
29
- self.the_role = rules_set.to_json if rules_set.is_a?(Hash) # 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
 
@@ -23,6 +23,7 @@ en:
23
23
  name: Name of role (underscored latin string)
24
24
  title: Title of role (text)
25
25
  description: Description of role (text)
26
+ based_on_role: "New role will be based on:"
26
27
  role:
27
28
  role_name: 'Role name:'
28
29
  title: 'Title:'
@@ -22,6 +22,7 @@ ru:
22
22
  name: Имя роли (строка из латинских символов + нижнее подчеркивание)
23
23
  title: Заголовок роли
24
24
  description: Описание роли
25
+ based_on_role: "Новая роль будет основана на:"
25
26
  role:
26
27
  role_name: 'Имя роли:'
27
28
  title: 'Заголовок:'
@@ -1,3 +1,3 @@
1
1
  module TheRole
2
- VERSION = "2.5.2"
2
+ VERSION = "2.5.3"
3
3
  end
@@ -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
- # "~> 2.5.1"
26
- path: '../../'
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.2
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-22 00:00:00.000000000 Z
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