humanity 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/humanity/base.rb +11 -3
- data/lib/humanity/version.rb +1 -1
- metadata +30 -49
data/lib/humanity/base.rb
CHANGED
@@ -30,11 +30,19 @@ module Humanity
|
|
30
30
|
|
31
31
|
def update_roles!(role_names, source)
|
32
32
|
prev_roles = self.roles
|
33
|
-
new_roles =
|
33
|
+
new_roles = if Role.respond_to? :find_or_create_by
|
34
|
+
role_names.map { |n| Role.find_or_create_by(name: n) }
|
35
|
+
else
|
36
|
+
role_names.map { |n| Role.find_or_create_by_name(n) }
|
37
|
+
end
|
34
38
|
|
35
39
|
# Create new roles and/or update source
|
36
40
|
new_roles.each do |role|
|
37
|
-
assignment = Assignment.
|
41
|
+
assignment = if Assignment.respond_to? :find_or_initialize_by
|
42
|
+
Assignment.find_or_initialize_by(human_id: self.id, human_type: self.class.to_s, role_id: role.id)
|
43
|
+
else
|
44
|
+
Assignment.find_or_initialize_by_human_id_and_human_type_and_role_id(self.id, self.class.to_s, role.id)
|
45
|
+
end
|
38
46
|
assignment.source = source
|
39
47
|
assignments << assignment if assignment.changed?
|
40
48
|
end
|
@@ -59,4 +67,4 @@ module Humanity
|
|
59
67
|
name
|
60
68
|
end
|
61
69
|
end
|
62
|
-
end
|
70
|
+
end
|
data/lib/humanity/version.rb
CHANGED
metadata
CHANGED
@@ -1,47 +1,38 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: humanity
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Adam Crownoble
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rails
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 7
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 3.0.0
|
34
22
|
type: :runtime
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
36
30
|
description: Mix in Humanity and get common user model functionality
|
37
31
|
email: adam.crownoble@biola.edu
|
38
32
|
executables: []
|
39
|
-
|
40
33
|
extensions: []
|
41
|
-
|
42
34
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
35
|
+
files:
|
45
36
|
- app/models/humanity/assignment.rb
|
46
37
|
- app/models/humanity/role.rb
|
47
38
|
- lib/humanity/version.rb
|
@@ -54,36 +45,26 @@ files:
|
|
54
45
|
- lib/humanity.rb
|
55
46
|
homepage: https://github.com/biola/humanity
|
56
47
|
licenses: []
|
57
|
-
|
58
48
|
post_install_message:
|
59
49
|
rdoc_options: []
|
60
|
-
|
61
|
-
require_paths:
|
50
|
+
require_paths:
|
62
51
|
- lib
|
63
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
53
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
|
70
|
-
- 0
|
71
|
-
version: "0"
|
72
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
59
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
version: "0"
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
81
64
|
requirements: []
|
82
|
-
|
83
65
|
rubyforge_project:
|
84
66
|
rubygems_version: 1.8.25
|
85
67
|
signing_key:
|
86
68
|
specification_version: 3
|
87
69
|
summary: Common user functionality
|
88
70
|
test_files: []
|
89
|
-
|