destiny-rails 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82e0fb482a9edca20552d9f0ccfb0c6347bcf20f
4
- data.tar.gz: d2445fe6d824947f555a5ef7e489daaa866ca2f5
3
+ metadata.gz: 173d0704bc5fdb1bc87e7c518970a2dfd8fcaee9
4
+ data.tar.gz: f56b0a58d4c2cafa45b299b550b54f59e6b8a018
5
5
  SHA512:
6
- metadata.gz: 0fdc6c8ebc179921ccaebf2ee4a460d0d2f4bbfa11115203b31113410fbc7a52729273dec8398220898df85d9f9b5f8095ef90811ef3e4f06aaee52cdcd35b32
7
- data.tar.gz: 6265aaf5476cf150d3eec2532f0f838748379f0c4b452165e686d6056c3fabcb0dc00525e66310dd51f49eb8a4b3d42d8ef9fc29ebfe28e9da026a4febcc5d0f
6
+ metadata.gz: 0db7fc4fe5a83877c7ffee456b3986d898a73ed13a4894569067e4b3ac05cbcb306f143f7fff92fbac2b973aa2e11ce408f1af2e9d7dc1297bcf55b34d27f8e2
7
+ data.tar.gz: e5e2459ef4b0567207748d1d0546b35926daaef209c442ec86b498a7f82aafa3b5190636f6767f03231edfc88b492c029318a50edc1218bc8c36de13296a671d
@@ -4,6 +4,10 @@ module Destiny
4
4
 
5
5
  included do
6
6
  has_and_belongs_to_many :roles, join_table: :users_roles
7
+
8
+ scope :with_role, ->(role_name) {
9
+ joins(:roles).where('roles.name = ?', role_name)
10
+ }
7
11
  end
8
12
 
9
13
  def permitted?(section_name, privilege)
@@ -30,13 +34,10 @@ module Destiny
30
34
 
31
35
  # compatibility with The_Role gem
32
36
  alias_method :admin?, :is_admin?
33
- alias_method :has_role?, :permitted?
34
37
  alias_method :has_grant?, :permitted?
35
38
 
36
- module ClassMethods
37
- def with_role(role_name)
38
- ::Role.find_by_name(role_name).try(:users)
39
- end
39
+ def has_role?(role_name)
40
+ roles.pluck(:name).count(role_name.to_s) > 0
40
41
  end
41
42
 
42
43
  end
@@ -1,3 +1,3 @@
1
1
  module Destiny
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: destiny-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Zhukov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-01 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler