cancancan-system 1.0.1 → 1.1.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
  SHA256:
3
- metadata.gz: b37daed7b5d3b0c495de6e7bc587dba3d6142f2c7f3eb661b5f18c7af50312f8
4
- data.tar.gz: dd5d14a8eef306541a19793abddff2a275b6105a60bf0293ab4cde8f91ed7b77
3
+ metadata.gz: 253f1db910ec70b137aae617ae0687b1a68d530867f2633a85c9af878b60d2f6
4
+ data.tar.gz: 60420111c58708ddc8ba58c3062db44f5421e8592475566e925d81259d50d54e
5
5
  SHA512:
6
- metadata.gz: 8e584e80ec587a3eb539e61154a55a7c07ff0106e1a883208517c1cd16676820186c34ecfa49be91ae85faedea0a4ccdcf979ef56050c480e3672b690350df36
7
- data.tar.gz: 6a9c6657c00a41538b757f7bebccbe30bb768298a6f02a23ea10524f9354c42608876b14ba9800bee7d124ea21a4515f9afddebb285f705e38fddda3a36dde58
6
+ metadata.gz: b0dc138a86917f2dfcc348372a0968dedb459a56ef01ece0fba04e962f717973fd8cf5dbcd2bcc3ba05b5b56b8c5f8926616dd9d0525bf15647172d1272a3dca
7
+ data.tar.gz: 7e6873d00dd8618f48bbbcf2b1c6324e18316cc3031ccf9264a744417f8485366384597fa582cceac0d56580145385ab6b928ac29d2224aa5705acdecfe56e3f
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 1.1.0 - 2018/01/21
8
+
9
+ * enhancements
10
+ * allow `column` option to be set to `nil` to use the `id` attribute
11
+
7
12
  ### 1.0.1 - 2018/01/21
8
13
 
9
14
  * bugfixes
data/README.md CHANGED
@@ -126,6 +126,8 @@ def initialize user
126
126
  end
127
127
  ```
128
128
 
129
+ **Note:** Set `column` to `nil` or `''` to use the `id` attribute.
130
+
129
131
  This is equivalent to:
130
132
 
131
133
  ```ruby
@@ -33,9 +33,9 @@ module CanCanCan
33
33
  public_abilities record_class if options[:public_abilities]
34
34
  if user
35
35
  if options[:polymorphic]
36
- can :manage, record_class, "#{options[:column]}_id": user.id, "#{options[:column]}_type": user.class.name
36
+ can :manage, record_class, "#{get_column(options[:column])}": user.id, "#{get_column(options[:column], 'type')}": user.class.name
37
37
  else
38
- can :manage, record_class, "#{options[:column]}_id": user.id
38
+ can :manage, record_class, "#{get_column(options[:column])}": user.id
39
39
  end
40
40
  yield if block_given?
41
41
  end
@@ -57,9 +57,9 @@ module CanCanCan
57
57
  can ability, record_class, "#{options[:column] || class_name.pluralize}": { id: belonging.belonger_id }
58
58
  else
59
59
  if options[:polymorphic]
60
- can ability, record_class, "#{options[:column] || class_name}_id": belonging.belonger_id, "#{options[:column] || class_name}_type": belonging.belonger_type
60
+ can ability, record_class, "#{get_column(options[:column] || class_name)}": belonging.belonger_id, "#{get_column(options[:column] || class_name, 'type')}": belonging.belonger_type
61
61
  else
62
- can ability, record_class, "#{options[:column] || class_name}_id": belonging.belonger_id
62
+ can ability, record_class, "#{get_column(options[:column] || class_name)}": belonging.belonger_id
63
63
  end
64
64
  end
65
65
  end
@@ -69,9 +69,9 @@ module CanCanCan
69
69
  can :manage, record_class, "#{options[:column] || class_name.pluralize}": { id: object.id }
70
70
  else
71
71
  if options[:polymorphic]
72
- can :manage, record_class, "#{options[:column] || class_name}_id": object.id, "#{options[:column] || class_name}_type": object.class.name
72
+ can :manage, record_class, "#{get_column(options[:column] || class_name)}": object.id, "#{get_column(options[:column] || class_name, 'type')}": object.class.name
73
73
  else
74
- can :manage, record_class, "#{options[:column] || class_name}_id": object.id
74
+ can :manage, record_class, "#{get_column(options[:column] || class_name)}": object.id
75
75
  end
76
76
  end
77
77
  end
@@ -142,6 +142,15 @@ module CanCanCan
142
142
  end
143
143
  end
144
144
 
145
+
146
+ def get_column column, name = 'id'
147
+ if column.nil? || column == ''
148
+ name
149
+ else
150
+ "#{column}_#{name}"
151
+ end
152
+ end
153
+
145
154
  end
146
155
  end
147
156
  end
@@ -1,7 +1,7 @@
1
1
  module CanCanCan
2
2
  module System
3
3
 
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
5
5
 
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cancancan-system
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter