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: f9da0a46c6938d58b83a1da33cf0a198c8f4f53f7c3bb4b96ee5467160c06370
4
- data.tar.gz: 6435ce69271ba313f1d02642d16ad24791cd4c2ea99e14be06782ceb4cc409e2
3
+ metadata.gz: 92cb8d28e2d00e637797983e7a92538e36b3096f417610f99b03675e418c495f
4
+ data.tar.gz: 8c3ad5a41b9f79ecbbf88577f93fd937454f6c472d68d8f05ecadd264fc4bece
5
5
  SHA512:
6
- metadata.gz: b35a6f53cd730eec70f2010332cbfd44c7e311b4341cf033b2b490069341b0e9fdad5bd607209b6ef63e1e9695dfcd5490b72d14a293aceed31159cacd2a30c9
7
- data.tar.gz: bea48fa8d635bbed0d2786b52c70b09a7e35629177bcda6f5218f1d7c83db5c1fe964f88243468d22b2753ee0a74223b6d3e91d47e67e8f5320a202bdb8942f5
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
- EffectiveResources.transaction do
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)
@@ -33,7 +33,7 @@ module Effective
33
33
 
34
34
  begin
35
35
  ActiveRecord::Base.transaction do
36
- resource.transaction do
36
+ EffectiveResources.transaction(resource) do
37
37
  run_callbacks(:resource_before_save)
38
38
 
39
39
  if resource.public_send("#{save_action}!") == false
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.0.1'.freeze
3
3
  end
@@ -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.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-09-28 00:00:00.000000000 Z
11
+ date: 2022-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails