sevn 0.0.4 → 0.0.5

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: c38d589954f038d8910248a485e444df0b45a10b
4
- data.tar.gz: 0319ee5a5c9a6aba41975f405ad503a09cf66fc3
3
+ metadata.gz: 46b95be0b2c9ccf2e306de969982bc3e5cc66abd
4
+ data.tar.gz: a348be59a8327b9d0b41ce31021fd6672208daaf
5
5
  SHA512:
6
- metadata.gz: 3e6cbfd5ba8ff4ad9a9a51a4ec752949cd36d6fc01f7d35724d7f6cbad0f5580cf337c9f15391c5e5506f51fa61cfdcff4a1d2ea83afd462abb24b25e2669c2b
7
- data.tar.gz: f9e583e7e09319401ad04494d7ecb2eb601f5c007e5e37d6523c90b9381d46d3e8d2e241d5079bb56541e1109409becce29d10d9bb3c5c0864994397889280e0
6
+ metadata.gz: 17b0f6b99014037c0a9b975fe7a0e8dd3b24e226ffafccfb626d5755f1d7db7f126d2cb0bcabd335f53ade6ea1203397779a33c93700c13fefa8d9f1c115d710
7
+ data.tar.gz: 7b56be6994f9ffc8512a7013f1ca93c6cca23ec24ccd1f38a622dc95e43c57d1794988d006267bf8784a9169846e77c80bc5c9ae883131de91834647ca213348
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v 0.0.5
2
+ - Translate rails CollectionProxy to array
1
3
  v 0.0.4
2
4
  - Bug fix of class not being initialized
3
5
  v 0.0.1
data/lib/sevn/ability.rb CHANGED
@@ -105,6 +105,10 @@ module Sevn
105
105
  end
106
106
 
107
107
  def action_allowed?(object, action, subjects, options)
108
+ if collection_proxy_defined? && subjects.class == ActiveRecord::Associations::CollectionProxy
109
+ subjects = subjects.to_a
110
+ end
111
+
108
112
  if subjects.kind_of?(Array)
109
113
  # if subjects is an Array, let's group them by class
110
114
  # check if action is allowed for the whole class or to all the subjects of that class
@@ -164,5 +168,10 @@ module Sevn
164
168
  tr("-", "_").
165
169
  downcase
166
170
  end
171
+
172
+ def collection_proxy_defined?
173
+ defined?(ActiveRecord::Associations::CollectionProxy) == 'constant' &&
174
+ ActiveRecord::Associations::CollectionProxy.class == Class
175
+ end
167
176
  end
168
177
  end
data/lib/sevn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sevn
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Cervera