effective_resources 2.34.5 → 2.35.0

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: c9835a4dc08eb19532186455423e0e1cc1dd0e9d155f9a8a21dd5ca9a1b57b56
4
- data.tar.gz: c71d543eaad1ab505e05da0cfecf6b13cc126d8f2f8ea0d998d36569a1cc0661
3
+ metadata.gz: ac9ab4beea90ef5e4c0bebd0ebb283b7315db417ced8324988c237e80825d3f6
4
+ data.tar.gz: b348baf50f92881cebbe44245a6a31dd623ca71b1d6810cff113143618dcea7f
5
5
  SHA512:
6
- metadata.gz: 6e7695631ef6abaf653f1a8e6dd888a4fe5606b240c269f2559cae16e12cc9d66ff8027724bdbc0f6c8ebd5d177d283124749c9d71641b5c0ff0f2d2fa783a3d
7
- data.tar.gz: 00a121d170c0daa7e00ac1ad5ad3a5cf1b20055636cfa2a4b6bdbfb7f4d66efbfdb0ed94a3f4db03bc470f5bd72154854ad5424a411f3f9fe2014b853520b107
6
+ metadata.gz: 4433a09b0d883ba4032b771cb0c795a6c5dc93b9d454ba23f8a82ecb54df5ee7dccb5e743e5b963e90007155ef8243c7616e0933cad46a88dfcf70d9265c1a81
7
+ data.tar.gz: b07e18cdd584d8f536a0bd6492358bc9b35bb6cc24765668e6c7370d33c9bb3111380368a8340830bc1e769af3ea0e5aadcc688d68a764f283a8a58c27ef3c1e
@@ -84,6 +84,14 @@ module Effective
84
84
  resource.created_by ||= (impersonation_user || current_user)
85
85
  end
86
86
 
87
+ if respond_to?(:current_user) && resource.respond_to?(:updated_by=)
88
+ resource.updated_by ||= (impersonation_user || current_user)
89
+ end
90
+
91
+ if resource.respond_to?(:current_path=)
92
+ resource.current_path ||= resource_path
93
+ end
94
+
87
95
  resource.assign_attributes(send(resource_params_method_name))
88
96
 
89
97
  EffectiveResources.authorize!(self, action, resource)
@@ -145,6 +153,10 @@ module Effective
145
153
  resource.updated_by ||= (impersonation_user || current_user)
146
154
  end
147
155
 
156
+ if resource.respond_to?(:current_path=)
157
+ resource.current_path ||= resource_path
158
+ end
159
+
148
160
  resource.assign_attributes(send(resource_params_method_name))
149
161
 
150
162
  if save_resource(resource, action)
@@ -201,6 +213,22 @@ module Effective
201
213
  to_assign = (send(resource_params_method_name) rescue {})
202
214
  resource.assign_attributes(to_assign) if to_assign.present? && to_assign.permitted?
203
215
 
216
+ if respond_to?(:current_user) && resource.respond_to?(:current_user=)
217
+ resource.current_user ||= current_user
218
+ end
219
+
220
+ if respond_to?(:current_user) && resource.respond_to?(:updated_by=)
221
+ resource.updated_by ||= (impersonation_user || current_user)
222
+ end
223
+
224
+ if respond_to?(:current_user) && resource.try(:new_record?) && resource.respond_to?(:created_by=)
225
+ resource.created_by ||= (impersonation_user || current_user)
226
+ end
227
+
228
+ if resource.respond_to?(:current_path=)
229
+ resource.current_path ||= resource_path
230
+ end
231
+
204
232
  if save_resource(resource, action)
205
233
  respond_with_success(resource, action)
206
234
  else
@@ -77,7 +77,7 @@ module Effective
77
77
 
78
78
  def notify_exception(exception, resource, action)
79
79
  if defined?(ExceptionNotifier)
80
- ExceptionNotifier.notify_exception(exception, env: request.env, data: { resource: resource, action: action })
80
+ EffectiveResources.send_error(exception, resource: resource, action: action)
81
81
  else
82
82
  raise(exception)
83
83
  end
@@ -150,6 +150,12 @@ module Effective
150
150
  datatable
151
151
  end
152
152
 
153
+ def resource_path
154
+ parts = controller_path.to_s.split('/')
155
+ parts.shift if defined?(Tenant) && parts.first == Tenant.current.to_s
156
+ parts.length > 1 ? parts.first.to_sym : nil
157
+ end
158
+
153
159
  def resource_layout
154
160
  namespace = controller_path.include?('admin/') ? 'admin' : 'application'
155
161
 
@@ -98,7 +98,7 @@ module ActsAsJobStatus
98
98
 
99
99
  if job_status == :error
100
100
  EffectiveLogger.error(exception.message, associated: self) if defined?(EffectiveLogger)
101
- ExceptionNotifier.notify_exception(exception, data: { id: id, class_name: self.class.name }) if defined?(ExceptionNotifier)
101
+ EffectiveResources.send_error(exception, id: id, class_name: self.class.name)
102
102
  end
103
103
 
104
104
  if job_status == :error && !ENV['TESTING_ACTS_AS_JOB_STATUS']
@@ -101,11 +101,11 @@ module EffectiveGem
101
101
 
102
102
  if associated.kind_of?(ActiveRecord::Base)
103
103
  EffectiveLogger.error(e.message, associated: associated, details: { email: email }) if defined?(EffectiveLogger)
104
- ExceptionNotifier.notify_exception(e, data: { email: email, associated_id: associated.id, associated_type: associated.class.name }) if defined?(ExceptionNotifier)
104
+ EffectiveResources.send_error(e, email: email, associated_id: associated.id, associated_type: associated.class.name)
105
105
  else
106
106
  args_to_s = args.to_s.gsub('<', '').gsub('>', '')
107
107
  EffectiveLogger.error(e.message, details: { email: email, args: args_to_s }) if defined?(EffectiveLogger)
108
- ExceptionNotifier.notify_exception(e, data: { email: email, args: args_to_s }) if defined?(ExceptionNotifier)
108
+ EffectiveResources.send_error(e, email: email, details: args_to_s)
109
109
  end
110
110
 
111
111
  raise(e) unless Rails.env.production? || Rails.env.staging?
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.34.5'.freeze
2
+ VERSION = '2.35.0'.freeze
3
3
  end
@@ -235,6 +235,25 @@ module EffectiveResources
235
235
  et(resource, attribute).pluralize.downcase
236
236
  end
237
237
 
238
+ def self.send_error(exception, **tags)
239
+ if defined?(Tenant)
240
+ tags = { tenant: Tenant.current || 'none' }.merge(tags)
241
+ end
242
+
243
+ tags = tags.transform_values(&:to_s)
244
+
245
+ if defined?(ExceptionNotifier)
246
+ ExceptionNotifier.notify_exception(exception, data: tags)
247
+ end
248
+
249
+ if defined?(Appsignal)
250
+ Appsignal.send_error(exception) do
251
+ Appsignal.add_tags(tags)
252
+ Appsignal.add_custom_data(tags)
253
+ end
254
+ end
255
+ end
256
+
238
257
  def self.cache_key(*keys)
239
258
  if defined?(Tenant)
240
259
  [Tenant.current] + Array(keys).flatten
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.34.5
4
+ version: 2.35.0
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: 2026-02-17 00:00:00.000000000 Z
11
+ date: 2026-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails