activerecord-duplicator 0.3.0 → 0.4.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4139cd9d1fa3041e02e9c17a2cf97c5f435230955c63b4ed29453b685fb6a985
|
|
4
|
+
data.tar.gz: 8acef30197ddd818ffc3e957bf7db58821e8ae8b34f848d72fdfd5f1713680f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22a435ec6ebc808da2a87bb20a4b19c82188c80ec73db48c39f33868f1729dc80775bae437f0b7e7b6d6dd86ae0e47862a72a3fb34e9e96d0c70ea50b5991bab
|
|
7
|
+
data.tar.gz: 5a5978f8259fde2473f220e8b2a953d649ae9c5824502ecb9a4c15bbfbbb9af9b2ae6cd5e9ebe89c5d5ea4a5d8c4de29e7c4efabe2058455d0197965f84fae3e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.4.0] - 2026-07-06
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- `Duplicator#duplicate` now accepts `transaction_options: {}` and forwards
|
|
8
|
+
it to `Session#run`, which forwards it to `root_record.transaction`. In
|
|
9
|
+
v0.3.0 this plumbing was only wired at the Session#run layer, so callers
|
|
10
|
+
using the documented `Duplicator#duplicate` entry point had no way to
|
|
11
|
+
override the outer transaction options.
|
|
12
|
+
|
|
3
13
|
## [0.3.0] - 2026-07-06
|
|
4
14
|
|
|
5
15
|
### Changed (breaking)
|
|
@@ -45,9 +45,7 @@ module ActiveRecord
|
|
|
45
45
|
# Duplicator-level handler is intentional and does not raise.
|
|
46
46
|
#: (Class) { (HandlerApi, Class, untyped) -> void } -> void
|
|
47
47
|
def on(klass, &block)
|
|
48
|
-
if @user_handlers.key?(klass)
|
|
49
|
-
raise DuplicateHandlerError, "handler for #{klass} is already overridden in this session"
|
|
50
|
-
end
|
|
48
|
+
raise DuplicateHandlerError, "handler for #{klass} is already overridden in this session" if @user_handlers.key?(klass)
|
|
51
49
|
|
|
52
50
|
@user_handlers[klass] = block
|
|
53
51
|
end
|
|
@@ -63,11 +63,15 @@ module ActiveRecord
|
|
|
63
63
|
# If a block is given it is called with the new Session before duplication
|
|
64
64
|
# starts, letting the caller mark_skip or store_new_id for records that
|
|
65
65
|
# were duplicated elsewhere.
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
#
|
|
67
|
+
# transaction_options is forwarded verbatim to Session#run, which forwards
|
|
68
|
+
# it to `root_record.transaction`. Default is `{}` (plain
|
|
69
|
+
# `transaction do ... end`).
|
|
70
|
+
#: (ActiveRecord::Base, ?associations: untyped, ?transaction_options: Hash[Symbol, untyped]) ?{ (Session) -> void } -> ActiveRecord::Base
|
|
71
|
+
def duplicate(root_record, associations: [], transaction_options: {}, &block)
|
|
68
72
|
session = Session.new(handlers: @handlers, skipped_classes: @skipped_classes)
|
|
69
73
|
block&.call(session)
|
|
70
|
-
session.run(root_record, associations:)
|
|
74
|
+
session.run(root_record, associations:, transaction_options:)
|
|
71
75
|
end
|
|
72
76
|
end
|
|
73
77
|
end
|
|
@@ -49,7 +49,11 @@ module ActiveRecord
|
|
|
49
49
|
# If a block is given it is called with the new Session before duplication
|
|
50
50
|
# starts, letting the caller mark_skip or store_new_id for records that
|
|
51
51
|
# were duplicated elsewhere.
|
|
52
|
-
#
|
|
53
|
-
|
|
52
|
+
#
|
|
53
|
+
# transaction_options is forwarded verbatim to Session#run, which forwards
|
|
54
|
+
# it to `root_record.transaction`. Default is `{}` (plain
|
|
55
|
+
# `transaction do ... end`).
|
|
56
|
+
# : (ActiveRecord::Base, ?associations: untyped, ?transaction_options: Hash[Symbol, untyped]) ?{ (Session) -> void } -> ActiveRecord::Base
|
|
57
|
+
def duplicate: (ActiveRecord::Base, ?associations: untyped, ?transaction_options: Hash[Symbol, untyped]) ?{ (Session) -> void } -> ActiveRecord::Base
|
|
54
58
|
end
|
|
55
59
|
end
|