activerecord-bitemporal 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97a21996b6ff931bf324653432cd481eac86731ee3de16445c98627987683639
4
- data.tar.gz: 34178dcfc6e5fe4cbd1f01554499f075d1be90208f05cc2d39a0039941d03607
3
+ metadata.gz: ff0157d808949658d0eb00a07b819670383ace1c7896537f6b6e5dfeda9e6c32
4
+ data.tar.gz: 1e14b06aac74ca12b3db6ee75144078eef8e793eda6048c7179fd8ef3025b01d
5
5
  SHA512:
6
- metadata.gz: da5f747f97ec3c16f14b65d592482b23cc8a0d8ba2d1c691dc98df8b5f84d5dfd8c92e8be67362f8b6be38b0bd584c2bfdd97f5169f9e4d91347a7286ad87770
7
- data.tar.gz: 2a1b5d95ac36a751943a87adcb9231b81633f61139a6ca38ca3d34859a7e9a2f647ce204b549eda50efca9cc48245d7aff7c21499397d4ef673d1f4c02de84a4
6
+ metadata.gz: 6e6ba80c96e30d975d5a1fe5edff0f631e8e4793d98c97e0c859d57948f5919d5aa47ab2990a456712888e8e25913bb370fc0bf3640c9d04eef3686774a00370
7
+ data.tar.gz: cd5d42d05eb0efe13355906b1547f86605aa1e327d1fae87aebb83475c4fe4162f2cba00875e92e6dcc497451d8a6c0bbe8bfffcbad543c972e5b229a05d0a60
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.3.0
4
+
5
+ ### Added
6
+
7
+ - [Add `previously_force_updated?` #142](https://github.com/kufu/activerecord-bitemporal/pull/142)
8
+
9
+ ### Changed
10
+
11
+ ### Deprecated
12
+
13
+ ### Removed
14
+
15
+ ### Fixed
16
+
17
+ ### Chores
18
+
19
+ - [Remove unneeded spec for Rails 5.x #143](https://github.com/kufu/activerecord-bitemporal/pull/143)
20
+
3
21
  ## 4.2.0
4
22
 
5
23
  ### Added
@@ -277,12 +277,13 @@ module ActiveRecord
277
277
  end
278
278
 
279
279
  refine ActiveRecord::Base do
280
- # MEMO: Do not copy `swapped_id`
280
+ # MEMO: Do not copy bitemporal internal status
281
281
  def dup(*)
282
282
  super.tap { |itself|
283
283
  itself.instance_exec do
284
284
  @_swapped_id_previously_was = nil
285
285
  @_swapped_id = nil
286
+ @previously_force_updated = false
286
287
  end unless itself.frozen?
287
288
  }
288
289
  end
@@ -320,6 +321,7 @@ module ActiveRecord
320
321
  before_instance&.save_without_bitemporal_callbacks!(validate: false)
321
322
  # NOTE: after_instance always exists
322
323
  after_instance.save_without_bitemporal_callbacks!(validate: false)
324
+ @previously_force_updated = self.force_update?
323
325
 
324
326
  # update 後に新しく生成したインスタンスのデータを移行する
325
327
  @_swapped_id_previously_was = swapped_id
@@ -345,6 +347,7 @@ module ActiveRecord
345
347
  @destroyed = false
346
348
  _run_destroy_callbacks {
347
349
  @destroyed = update_transaction_to(operated_at)
350
+ @previously_force_updated = force_update?
348
351
 
349
352
  # force_update の場合は削除時の状態の履歴を残さない
350
353
  unless force_update?
@@ -397,6 +400,7 @@ module ActiveRecord
397
400
  # NOTE: Hook to copying swapped_id
398
401
  @_swapped_id_previously_was = nil
399
402
  @_swapped_id = fresh_object.swapped_id
403
+ @previously_force_updated = false
400
404
  self
401
405
  end
402
406
  elsif Gem::Version.new("6.1.0") <= ActiveRecord.version
@@ -420,6 +424,7 @@ module ActiveRecord
420
424
  # NOTE: Hook to copying swapped_id
421
425
  @_swapped_id_previously_was = nil
422
426
  @_swapped_id = fresh_object.swapped_id
427
+ @previously_force_updated = false
423
428
  self
424
429
  end
425
430
  else
@@ -442,6 +447,7 @@ module ActiveRecord
442
447
  # NOTE: Hook to copying swapped_id
443
448
  @_swapped_id_previously_was = nil
444
449
  @_swapped_id = fresh_object.swapped_id
450
+ @previously_force_updated = false
445
451
  self
446
452
  end
447
453
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Bitemporal
5
- VERSION = "4.2.0"
5
+ VERSION = "4.3.0"
6
6
  end
7
7
  end
@@ -104,6 +104,10 @@ module ActiveRecord::Bitemporal::Bitemporalize
104
104
  swapped_id.presence || super
105
105
  end
106
106
 
107
+ def previously_force_updated?
108
+ @previously_force_updated
109
+ end
110
+
107
111
  def valid_from_cannot_be_greater_equal_than_valid_to
108
112
  if valid_from && valid_to && valid_from >= valid_to
109
113
  errors.add(:valid_from, "can't be greater equal than valid_to")
@@ -141,10 +145,12 @@ module ActiveRecord::Bitemporal::Bitemporalize
141
145
  # MEMO: #update_columns is not call #_update_row (and validations, callbacks)
142
146
  update_columns(bitemporal_id_key => swapped_id) unless send(bitemporal_id_key)
143
147
  swap_id!(without_clear_changes_information: true)
148
+ @previously_force_updated = false
144
149
  end
145
150
 
146
151
  after_find do
147
152
  self.swap_id! if self.send(bitemporal_id_key).present?
153
+ @previously_force_updated = false
148
154
  end
149
155
 
150
156
  # Callback hook to `validates :xxx, uniqueness: true`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-bitemporal
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SmartHR
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord