status_assignable 0.1.6 → 0.1.8

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: 7ef254faf75f8c06ff1ea2f1efffc4e2e46478639c34ce33b04adf754d6eb8e4
4
- data.tar.gz: 36c35683c70b07612c84a793be219f548bb816f3fcdeef58995227a37872f59c
3
+ metadata.gz: a8774bcf6d0aea82d8bd5ff24c82ff64336c54318e2a75ef0194b73aaadebcfe
4
+ data.tar.gz: 302d529d43f1fff2e8d553091431e16e1fc8b99b173d0aa0529e2bb134968161
5
5
  SHA512:
6
- metadata.gz: 64cf25ad1f86c9a1f86087ad2b2c53a4aec9b2da405dd9846f4c3f0e0efac04e6315644b83a1e3f53561b5daefbf8bb58023519ea15330b8309df9945e2c0111
7
- data.tar.gz: 4b8d9eec55606e7e29b2526cefcc5a2786d4e982852e87760894b1ca2e18e6f1057c17dac2a2a43103c40c0ddf52c9d0ef6944f924f5e1f865d75187dc400def
6
+ metadata.gz: 0a484bc3b5ba125a393af899c0b7e9cd185c52c6d8f6c5cf9f3b60b45ef46a5470db7a94156957639c0f2dd1d79a409a3c099d743b224b5e6e8905d7d997b800
7
+ data.tar.gz: 74cd75459f98d148012107be61ec2109fe71bef6add3660a9a4551373ddb4f99acfcc2a9f50f6ba327199795d29cb85c1207ff33a8499608b5d07a9ddf1b5440
data/README.md CHANGED
@@ -88,10 +88,11 @@ class User < ApplicationRecord
88
88
 
89
89
  has_many :posts, dependent: :destroy, archive: :callbacks
90
90
  has_many :comments, dependent: :delete_all, archive: :assign
91
+ has_many :favorites, dependent: :destroy, archive: :destroy
91
92
  end
92
93
  ```
93
94
 
94
- The `archive` option can be set to `:callbacks` or `:assign`. If set to `:callbacks`, the associated records will be archived using `soft_destroy`. If set to `:assign`, the associated records will have their status columns assigned directly.
95
+ The `archive` option can be set to `:callbacks`, `:assign` or `:destroy`. If set to `:callbacks`, the associated records will be archived using `soft_destroy`. If set to `:assign`, the associated records will have their status columns assigned directly. If set to `:destroy`, the associated records will be directly destroyed.
95
96
 
96
97
  It is important that the associations also are `StatusAssignable`!
97
98
 
@@ -5,7 +5,7 @@ module StatusAssignable
5
5
  # The values accepted by the :archive option are :callbacks and :assign.
6
6
  module Association
7
7
  CUSTOM_VALID_OPTIONS = [:archive].freeze
8
- VALID_ARCHIVE_OPTIONS = %i[callbacks assign].freeze
8
+ VALID_ARCHIVE_OPTIONS = %i[callbacks assign destroy].freeze
9
9
 
10
10
  private
11
11
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StatusAssignable
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.8'
5
5
  end
@@ -97,6 +97,7 @@ module StatusAssignable
97
97
  case archive_procedure
98
98
  when :callbacks then callbacks_method(query)
99
99
  when :assign then assign_method(query)
100
+ when :destroy then destroy_method(query)
100
101
  end
101
102
  end
102
103
  end
@@ -108,6 +109,10 @@ module StatusAssignable
108
109
  def assign_method(query)
109
110
  query.respond_to?(:update_all) ? query.update_all(archive_params) : query&.update_columns(archive_params)
110
111
  end
112
+
113
+ def destroy_method(query)
114
+ query.respond_to?(:each) ? query.each(&:destroy) : query&.destroy
115
+ end
111
116
  end
112
117
  end
113
118
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: status_assignable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-03 00:00:00.000000000 Z
10
+ date: 2025-03-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails