humanity 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 74186ca2f9630a45790c206f128beb02e5e7d2ec
4
+ data.tar.gz: 3c619855da67acb124e89d8d230c85bbf3e4b79c
5
+ SHA512:
6
+ metadata.gz: db414b932a3a369da51aa1da46944f24ff892489a83457d5d6f0fdb52df6ea73dbeedbd28d4c7feceff92b16ccf87e735547535ee8772062e30bf71f42bade37
7
+ data.tar.gz: ac55e10861a705e15813db167e11dc40f205a09db4b55617fa135b307facfdd7925291036d95ce63ff15f1807b34bffcd8083ac287b400b09eb83b4d56dc12f4
@@ -6,6 +6,10 @@ module Humanity
6
6
 
7
7
  base.validates_presence_of :username
8
8
  base.validates_uniqueness_of :username
9
+
10
+ Role.class_eval do
11
+ has_many :humans, through: :assignments, source_type: base.to_s
12
+ end
9
13
  end
10
14
 
11
15
  def name
@@ -16,8 +20,8 @@ module Humanity
16
20
  roles.map(&:to_sym)
17
21
  end
18
22
 
19
- def has_role?(role)
20
- roles.where(name: role.to_s).first.present?
23
+ def has_role?(*role)
24
+ roles.where(name: role.flatten.map(&:to_s)).any?
21
25
  end
22
26
 
23
27
  def admin?
@@ -29,6 +33,8 @@ module Humanity
29
33
  end
30
34
 
31
35
  def update_roles!(role_names, source)
36
+ source = source.to_s unless source.nil?
37
+
32
38
  prev_roles = self.roles
33
39
  new_roles = if Role.respond_to? :find_or_create_by
34
40
  role_names.map { |n| Role.find_or_create_by(name: n) }
@@ -1,3 +1,3 @@
1
1
  module Humanity
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humanity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Adam Crownoble
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.0.0
30
27
  description: Mix in Humanity and get common user model functionality
@@ -44,27 +41,27 @@ files:
44
41
  - lib/generators/humanity/templates/create_users.rb
45
42
  - lib/humanity.rb
46
43
  homepage: https://github.com/biola/humanity
47
- licenses: []
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
48
47
  post_install_message:
49
48
  rdoc_options: []
50
49
  require_paths:
51
50
  - lib
52
51
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
52
  requirements:
55
- - - ! '>='
53
+ - - '>='
56
54
  - !ruby/object:Gem::Version
57
55
  version: '0'
58
56
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
57
  requirements:
61
- - - ! '>='
58
+ - - '>='
62
59
  - !ruby/object:Gem::Version
63
60
  version: '0'
64
61
  requirements: []
65
62
  rubyforge_project:
66
- rubygems_version: 1.8.25
63
+ rubygems_version: 2.1.11
67
64
  signing_key:
68
- specification_version: 3
65
+ specification_version: 4
69
66
  summary: Common user functionality
70
67
  test_files: []