i_am_i_can 4.1.0 → 4.2.0

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: f5c54e75b43df8cbfb0e8acd30cb0fc40e0aeda0
4
- data.tar.gz: 5a0a6c5198cdb76ca0a251b99d7320cc2a081854
3
+ metadata.gz: edde7fa4072a2d78c7b5017f9d42e0aab9925f1f
4
+ data.tar.gz: 99d658e9ce576ed82207f577cfcba96202a6cdfc
5
5
  SHA512:
6
- metadata.gz: 00ed26e8fe4e750241e92eda7d5acb084bc3a733f654af380e61f052c8723c62e5f8b82ef9e1907466caf02a8f7a2cc6c2d30fd44a20848b60965e53333e65f1
7
- data.tar.gz: f6d4a8bbab40bfe9017f38a0f7acc63aa5784743e279a15c4b26611bab9ee8f39d1c58e572de1f48b9acfc36d464454869be057354329dad5119bc14d5bde1a3
6
+ metadata.gz: 195ed325b75c8b7a7b7e94cb6cd601214451044f438f25c26c357187d9cd229ca5c37000cf5ca28b03f95b22964be0f3e7131f4c4cc36926036ccc75d9871d2b
7
+ data.tar.gz: 96a3122e55433bfb0115051c4da61fd465d9909e4d977fb7a84819d8dd88c310aa87e58ea30397c9bdb2fb71bb27362f4fc5ddfa136f3f8ef5d8dc551a2c37dd
@@ -25,11 +25,18 @@ module IAmICan
25
25
  end
26
26
  end
27
27
 
28
- def _permissions_assignment(action = :assign, actions, obj)
29
- permissions = actions.product(Array[obj]).map { |(p, o)| { action: p, **deconstruct_obj(o) } }
30
- assignment = _stored_permissions_exec(action,
31
- permissions.reduce({ }) { |a, b| a.merge(b) { |_, x, y| [x, y] } })
32
- ResultOf.permission assignment, i_am_i_can, given: [[], permissions.map { |pms| pms.values.compact.join('_').to_sym }]
28
+ def _permissions_assignment(exec = :assign, actions, obj)
29
+ if actions.first.is_a?(i_am_i_can.permission_model)
30
+ exec_arg, names = actions, actions.map(&:name)
31
+ else
32
+ objs = obj ? Array(obj) : [nil]
33
+ permissions = actions.product(objs).map { |(p, o)| { action: p, **deconstruct_obj(o) } }
34
+ exec_arg = permissions.reduce({ }) { |a, b| a.merge(b) { |_, x, y| [x, y] } }
35
+ names = permissions.map { |pms| pms.values.compact.join('_').to_sym }
36
+ end
37
+
38
+ assignment = _stored_permissions_exec(exec, exec_arg)
39
+ ResultOf.permission assignment, i_am_i_can, given: [[], names]
33
40
  end
34
41
  end
35
42
  end
@@ -1,3 +1,3 @@
1
1
  module IAmICan
2
- VERSION = '4.1.0'
2
+ VERSION = '4.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i_am_i_can
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhandao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-08 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler