cant_cant_cant 0.1.7 → 0.1.8

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cant_cant_cant.rb +6 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0cbbfafb5251a59ebfcd83be030095d7f592fca
4
- data.tar.gz: 2550913d0b8c3d464f8590c47627f3b67479aede
3
+ metadata.gz: 044a8b09b8b90ccb706fc099ae7157a2663db589
4
+ data.tar.gz: a4bed21f82d41c8618bb743091f655f08c3534e8
5
5
  SHA512:
6
- metadata.gz: a2c95d0766a84c66f36867f24bc1a576dd8ccd3a6bb8c9e3637d93ccd6c248286c614918e45d5e302a3b1e9ec6b7f7596a58989101fb1c7018ba90cdbd693039
7
- data.tar.gz: 0507ed6001d256ad501b16d62c8523e7554f6fbcd99ff07b8cd03f14ad117cfa95ae22612d918843bc0d45bce9129b19ba6e13f08919e54cba27b17845119a96
6
+ metadata.gz: 0cb4ee118ea0f164933bce0fdaa7daaaa4c260c2e10a55f6e17257d24eec9b414fb4ec979c545dc5589ef0201ab78b9fb9ecd81ed707081ac1e5da485f6a2bbb
7
+ data.tar.gz: 16922ea55999cb78a4c21946fdcba7e034e2d9b2ae11c3063a244eed424d1742ceacb4a4b93c32e89bdb934353eef6b61c249ca7feb7db401b4ce66a973ae30a
@@ -25,9 +25,10 @@ module CantCantCant
25
25
  end
26
26
 
27
27
  def permissions_for(roles)
28
+ roles = [roles] unless roles.is_a? Array
28
29
  @cache[roles.sort.join(',')] ||=
29
30
  permission_table
30
- .values_at(*roles)
31
+ .values_at(*roles.map(:to_s))
31
32
  .select(&:present?)
32
33
  .map { |x| x.keep_if { |_, v| v == 'allow' }.keys }
33
34
  .flatten
@@ -53,9 +54,10 @@ module CantCantCant
53
54
  def inject_action(param)
54
55
  controller_class, action = extract_controller(param)
55
56
  controller_class.class_eval do
56
- before_action(only: [action]) do
57
- next true if CantCantCant.allow?(param, current_roles)
58
- raise PermissionDenied, param
57
+ before_action(only: action) do
58
+ roles = current_roles
59
+ next true if CantCantCant.allow?(param, roles)
60
+ raise PermissionDenied, [param, roles]
59
61
  end
60
62
  end
61
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cant_cant_cant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shou Ya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-11 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails