effective_resources 2.0.0 → 2.0.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92cb8d28e2d00e637797983e7a92538e36b3096f417610f99b03675e418c495f
|
4
|
+
data.tar.gz: 8c3ad5a41b9f79ecbbf88577f93fd937454f6c472d68d8f05ecadd264fc4bece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a69b8c4224eeac5e5ef2c6e9bf537b562e02dc3c194cb82f0c4a001ff3485a2895111433fbf8058a1e7b92fd3eead3d19c0cf9bbee98b79b86570607db704727
|
7
|
+
data.tar.gz: ac9e60af57f79f860cadeb4263d1f898b3814188f07c7625fe070f25689cbbe93357a07a93e3c679e4d281c145e7f810e693dee5bfc5640e439e36e92955c475
|
@@ -228,7 +228,7 @@ module Effective
|
|
228
228
|
|
229
229
|
# No attributes are assigned or saved. We purely call action! on the resource
|
230
230
|
|
231
|
-
|
231
|
+
ActiveRecord::Base.transaction do
|
232
232
|
successes = resources.select do |resource|
|
233
233
|
begin
|
234
234
|
resource.public_send("#{action}!") if EffectiveResources.authorized?(self, action, resource)
|
data/lib/effective_resources.rb
CHANGED
@@ -159,4 +159,17 @@ module EffectiveResources
|
|
159
159
|
duplicate
|
160
160
|
end
|
161
161
|
|
162
|
+
def self.transaction(resource = nil, &block)
|
163
|
+
raise('expected a block') unless block_given?
|
164
|
+
|
165
|
+
if resource.respond_to?(:transaction)
|
166
|
+
resource.transaction { yield }
|
167
|
+
elsif resource.class.respond_to?(:transaction)
|
168
|
+
resource.class.transaction { yield }
|
169
|
+
else
|
170
|
+
ActiveRecord::Base.transaction { yield }
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
162
175
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|