status_assignable 0.1.5 → 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: d8777966d201fcf5ac954f3a5b9c5644e3cad4571302620d1360586283305463
4
- data.tar.gz: 986eb2bfb974907993c37d2f188d5f02f71c4ac602f34ecad56be1731b16b1c7
3
+ metadata.gz: a8774bcf6d0aea82d8bd5ff24c82ff64336c54318e2a75ef0194b73aaadebcfe
4
+ data.tar.gz: 302d529d43f1fff2e8d553091431e16e1fc8b99b173d0aa0529e2bb134968161
5
5
  SHA512:
6
- metadata.gz: 9c359e3da1f941b16625e025c6a529fe4b709d9d96f785208e08c422da3782fecae4eb5e4338c80969e62c79f42c9e50ee504ea702ff8d156d1009cf46f3c532
7
- data.tar.gz: 2f9d55b795d48c4c42c962d82551451df24b36d612403c8b02fdd7b7f1fc80059ef7b3f8aa22fec49f9f48c19eaa0d2f786e8c2b2e39506d39e13f00c87fe1c9
6
+ metadata.gz: 0a484bc3b5ba125a393af899c0b7e9cd185c52c6d8f6c5cf9f3b60b45ef46a5470db7a94156957639c0f2dd1d79a409a3c099d743b224b5e6e8905d7d997b800
7
+ data.tar.gz: 74cd75459f98d148012107be61ec2109fe71bef6add3660a9a4551373ddb4f99acfcc2a9f50f6ba327199795d29cb85c1207ff33a8499608b5d07a9ddf1b5440
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.1
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,19 +5,19 @@ 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
 
12
12
  def valid_options(options)
13
- super(options) + CUSTOM_VALID_OPTIONS
13
+ super + CUSTOM_VALID_OPTIONS
14
14
  end
15
15
 
16
16
  def define_callbacks(model, reflection)
17
17
  if (archive_option_value = reflection.options[:archive])
18
18
  check_archive_options(archive_option_value)
19
19
  end
20
- super(model, reflection)
20
+ super
21
21
  end
22
22
 
23
23
  def check_archive_options(archive_option_value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StatusAssignable
4
- VERSION = '0.1.5'
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
 
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ['lib']
28
28
 
29
29
  # Uncomment to register a new dependency of your gem
30
- spec.add_dependency 'rails', '~> 7.1'
30
+ spec.add_dependency 'rails', '>= 7.1', '< 9'
31
31
 
32
32
  # For more information and examples about making a new gem, check out our
33
33
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,36 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: status_assignable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-01-27 00:00:00.000000000 Z
10
+ date: 2025-03-06 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '7.1'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '9'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
- - - "~>"
26
+ - - ">="
25
27
  - !ruby/object:Gem::Version
26
28
  version: '7.1'
27
- description:
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '9'
28
32
  email:
29
33
  - tieeeeen1994@gmail.com
30
34
  executables: []
31
35
  extensions: []
32
36
  extra_rdoc_files: []
33
37
  files:
38
+ - ".ruby-version"
34
39
  - CODE_OF_CONDUCT.md
35
40
  - LICENSE.txt
36
41
  - README.md
@@ -47,7 +52,6 @@ licenses:
47
52
  metadata:
48
53
  homepage_uri: https://github.com/tieeeeen1994/rails-status-assignable
49
54
  rubygems_mfa_required: 'true'
50
- post_install_message:
51
55
  rdoc_options: []
52
56
  require_paths:
53
57
  - lib
@@ -62,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
66
  - !ruby/object:Gem::Version
63
67
  version: '0'
64
68
  requirements: []
65
- rubygems_version: 3.5.23
66
- signing_key:
69
+ rubygems_version: 3.6.5
67
70
  specification_version: 4
68
71
  summary: Allows models to be assigned a status.
69
72
  test_files: []