effective_resources 2.34.5 → 2.34.6

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: 3a79c20ed1ee3e1431b0bd8c48b3dba8e79b32399b47ae79112c0a12442f1086
4
+ data.tar.gz: d26fa6a177b49e83a063dd109c96188455817537c77ade219a54004ebc90dff9
5
5
  SHA512:
6
- metadata.gz: 6e7695631ef6abaf653f1a8e6dd888a4fe5606b240c269f2559cae16e12cc9d66ff8027724bdbc0f6c8ebd5d177d283124749c9d71641b5c0ff0f2d2fa783a3d
7
- data.tar.gz: 00a121d170c0daa7e00ac1ad5ad3a5cf1b20055636cfa2a4b6bdbfb7f4d66efbfdb0ed94a3f4db03bc470f5bd72154854ad5424a411f3f9fe2014b853520b107
6
+ metadata.gz: caaf3fa64b831e26364daaa80fede1bb5555de2425fcd201bcd3a8e364bb6af2dff1d52f29c2332504816317c59972a80c45fbb64596c91c9b7ef84f62212f78
7
+ data.tar.gz: 6c8be7d92251017a58bc2cf6e0e5a8125a63b12225e9b187ad2f2809972d5ed2aa839126580c9b0ffde69a82d1d9b9b0eee0d902b780166ec0abfde83c10c11a
@@ -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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.34.5'.freeze
2
+ VERSION = '2.34.6'.freeze
3
3
  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.34.5
4
+ version: 2.34.6
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-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails