effective_resources 1.19.1 → 2.0.1
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
|
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)
|
@@ -55,14 +55,14 @@ module Effective
|
|
55
55
|
|
56
56
|
if exception.present?
|
57
57
|
Rails.logger.info " \e[31m\e[1mFAILED\e[0m\e[22m" # bold red
|
58
|
-
Rails.logger.info " Unable to #{action} #{resource} - #{
|
58
|
+
Rails.logger.info " Unable to #{action} #{resource} - #{exception.class} #{exception}"
|
59
59
|
exception.backtrace.first(5).each { |line| Rails.logger.info(' ' + line) }
|
60
60
|
|
61
61
|
if resource.respond_to?(:restore_attributes) && resource.persisted?
|
62
62
|
resource.restore_attributes(['status', 'state'])
|
63
63
|
end
|
64
64
|
|
65
|
-
flash.now[:danger] = resource_flash(:danger, resource, action, e:
|
65
|
+
flash.now[:danger] = resource_flash(:danger, resource, action, e: exception)
|
66
66
|
|
67
67
|
if exception.kind_of?(ActiveRecord::StaleObjectError)
|
68
68
|
flash.now[:danger] = "#{flash.now[:danger]} <a href='#', class='alert-link' onclick='window.location.reload(true); return false;'>reload page and try again</a>"
|
data/lib/effective_resources.rb
CHANGED
@@ -86,10 +86,6 @@ module EffectiveResources
|
|
86
86
|
klass
|
87
87
|
end
|
88
88
|
|
89
|
-
def self.transaction(resource = nil, &block)
|
90
|
-
resource.class.transaction { yield }
|
91
|
-
end
|
92
|
-
|
93
89
|
# Used by streaming CSV export in datatables
|
94
90
|
def self.with_resource_enumerator(&block)
|
95
91
|
raise('expected a block') unless block_given?
|
@@ -163,4 +159,17 @@ module EffectiveResources
|
|
163
159
|
duplicate
|
164
160
|
end
|
165
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
|
+
|
166
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:
|
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
|