effective_resources 2.36.5 → 2.37.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: '086e9b2c0d5f9e843a39a880c48ca7467c454d96d426b7a789f474ed6db2d37f'
4
- data.tar.gz: 7ad84343ab0180ecb8b2c73a767af2904f23b27f4d497fe3f45f729abed23337
3
+ metadata.gz: 34000b998f97e0525a90ba9ee7691dc4b114460e4bbf6e0f25dd17e428408a4a
4
+ data.tar.gz: 2e546baaa6091446448894796e9ab8869532f9dd68c478e96bf3a9d749adb511
5
5
  SHA512:
6
- metadata.gz: cf277644616c40600656c124b3982f5a39e27a87805b2b38d11adde65ae58672d974488d7745ee141724cf05a8a9a2dac9b37d8a42e1cfd05177a358e4be63dc
7
- data.tar.gz: 0c70a0926f46a18b73edb4a045bd7b1764dccab54e610aa4e389ea129024c7b1e9f48e1c9f2b660d2087e4ea18b45dffbdbbc2f90764176141032058bf329e12
6
+ metadata.gz: 4ecc3665cc1e92b791074c01921ef422310ed10706b6f0948f9b13e4a4a3be537e562e6e0e043e55736738a6afe94e78f9fb9d9a0ae96173827c8c707a5d479b
7
+ data.tar.gz: f53e5948e27a4b43155a3ec53de5085389d917932f020acb929142b13cefa050baccc54e8beeee58161f72ef371609cdc7707884c868ac287618118165011635
@@ -250,9 +250,11 @@ module ActsAsPurchasableWizard
250
250
  end
251
251
 
252
252
  # A hook to extend
253
+ # These are not for use when extending a fee payment
253
254
  def before_submit_purchased!
254
255
  end
255
256
 
257
+ # These are not for use when extending a fee payment
256
258
  def after_submit_purchased!
257
259
  end
258
260
 
@@ -269,6 +271,14 @@ module ActsAsPurchasableWizard
269
271
  wizard_steps[:checkout] ||= Time.zone.now
270
272
  wizard_steps[:submitted] = Time.zone.now
271
273
  submitted!
274
+
275
+ after_submit!
276
+
277
+ true
278
+ end
279
+
280
+ # A hook to extend. Safe for fee payments.
281
+ def after_submit!
272
282
  end
273
283
 
274
284
  module ClassMethods
@@ -5,8 +5,8 @@
5
5
  #
6
6
  # Pass 'has_many_purgable :files, :avatar' to only allow the files and avatar to be purged.
7
7
  #
8
- # Works with effective_bootstrap file_field to display a Delete file on save checkbox
9
- # to submit a _purge array of attachments to purge.
8
+ # Works with effective_bootstrap file_field, which renders a Remove button per attachment
9
+ # that submits the attachment's signed_id in the _purge array.
10
10
  #
11
11
  # You must permit the attribute _purge: []
12
12
 
@@ -53,34 +53,33 @@ module HasManyPurgable
53
53
  # All the possible names, merging the actual associations and the given options
54
54
  def has_many_purgable_names
55
55
  names = has_many_purgable_options.fetch(:names)
56
-
57
- associations = self.class.reflect_on_all_associations
58
- .select { |ass| ass.class_name == 'ActiveStorage::Attachment' }
59
- .map { |ass| ass.name.to_s.chomp('_attachments').chomp('_attachment').to_sym }
60
-
56
+ associations = self.class.attachment_reflections.keys.map(&:to_sym)
61
57
  names == :all ? associations : (names & associations)
62
58
  end
63
59
 
64
60
  private
65
61
 
66
- # As submitted by the form and permitted by our associations and options
62
+ # Returns the ActiveStorage::Attachment records selected for purging, matched by signed_id.
67
63
  def has_many_purgable_attachments
68
- submitted = (Array(_purge) - [nil, '', '0', ' ', 'false', 'f', 'off']).map(&:to_sym)
69
- submitted & has_many_purgable_names
64
+ submitted = Array(_purge) - [nil, '', '0', ' ', 'false', 'f', 'off']
65
+ return [] if submitted.blank?
66
+
67
+ all_attachments = has_many_purgable_names.flat_map { |name| Array(public_send(name)) }
68
+ all_attachments.select { |attachment| submitted.include?(attachment.signed_id) }
70
69
  end
71
70
 
72
71
  def has_many_purgable_mark_for_destruction
73
- has_many_purgable_attachments.each do |name|
74
- Array(public_send(name)).each { |attachment| attachment.mark_for_destruction unless attachment.new_record? }
72
+ has_many_purgable_attachments.each do |attachment|
73
+ attachment.mark_for_destruction unless attachment.new_record?
75
74
  end
76
75
 
77
76
  true
78
77
  end
79
78
 
80
79
  def has_many_purgable_purge
81
- has_many_purgable_attachments.each do |name|
82
- Rails.logger.info "[has_many_purgable] Purging #{name} attachments"
83
- Array(public_send(name)).each { |attachment| attachment.purge if attachment.marked_for_destruction? }
80
+ has_many_purgable_attachments.each do |attachment|
81
+ Rails.logger.info "[has_many_purgable] Purging attachment #{attachment.id} (#{attachment.name})"
82
+ attachment.purge if attachment.marked_for_destruction?
84
83
  end
85
84
 
86
85
  true
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.36.5'.freeze
2
+ VERSION = '2.37.0'.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.36.5
4
+ version: 2.37.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-03-25 00:00:00.000000000 Z
11
+ date: 2026-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails