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: ee612e84f80aefec6371c6e900d058e9934b7b7d095a981e2f52d22291586210
4
- data.tar.gz: 2aafb86816d74188a18a82e36c74e1a6c1dcb65b52523c3ee4bafa9db45e1fa3
3
+ metadata.gz: 4139cd9d1fa3041e02e9c17a2cf97c5f435230955c63b4ed29453b685fb6a985
4
+ data.tar.gz: 8acef30197ddd818ffc3e957bf7db58821e8ae8b34f848d72fdfd5f1713680f4
5
5
  SHA512:
6
- metadata.gz: f167f08df7e50cc605ff85d3663f3e51cb1b2a11ea88201bf50726b20721e263b8b9f96fee38ad64e42b97cd895f2217fb1968760bdf085351959632c7fec0d1
7
- data.tar.gz: 652d33cc38a670dc0eafad296157d6f56c5fd3e4a435082b1bec45706c9a01624730be36992ebd22ac88f335a70def57aad3234480d77816297f879460462cda
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  class Duplicator
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  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
- #: (ActiveRecord::Base, ?associations: untyped) ?{ (Session) -> void } -> ActiveRecord::Base
67
- def duplicate(root_record, associations: [], &block)
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
- # : (ActiveRecord::Base, ?associations: untyped) ?{ (Session) -> void } -> ActiveRecord::Base
53
- def duplicate: (ActiveRecord::Base, ?associations: untyped) ?{ (Session) -> void } -> ActiveRecord::Base
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-duplicator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SmartHR